Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

(0) ShareShare
ReportReport
Posted on by 65

 we had developed a custom application for MS CRM 4.0 for this we had used;

i. ./CrmService.asmx

ii. ./MetadataService.asmx

this is a sample function 

Please support to upgrade the below function to CRM 2013 , then 2015

2007/WebServices is not supported in 2013 .

function new_vatgroup_onchange()
{


if (crmForm.all.new_vatgroupid.DataValue != null)
{
var vatgroupID= crmForm.all.new_vatgroupid.DataValue[0].id;

var authenticationHeader = GenerateAuthenticationHeader();

var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='">schemas.xmlsoap.org/.../'"
" xmlns:xsi='">www.w3.org/.../XMLSchema-instance'"
" xmlns:xsd='">www.w3.org/.../XMLSchema'>"
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='">schemas.microsoft.com/.../WebServices'>"
"<entityName>new_vatgroup</entityName>"+
"<id>" + vatgroupID + "</id>"+
"<columnSet xmlns:q1='schemas.microsoft.com/.../Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>new_vatvalues</q1:Attribute>"+

"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";

var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","">schemas.microsoft.com/.../Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);

var resultXml = xHReq.responseXML;

var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
else
{

//filterSubGrid();
/////
var paymentamountValue = Xrm.Page.getAttribute("new_paymentamount").getValue();
//if (optValue == 0) {


// crmForm.all.new_vatgroupvalue.DataValue = 0.06;

var VARvatgroupvalu = parseFloat(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue)
crmForm.all.new_vatgroupvalue.DataValue=(VARvatgroupvalu);
crmForm.all.new_vatvalue.DataValue=(0);
crmForm.all.new_dueamount.DataValue=(paymentamountValue);

if (VARvatgroupvalu !=0) {
var VARValue= (paymentamountValue * VARvatgroupvalu);
crmForm.all.new_vatvalue.DataValue=(VARValue);
crmForm.all.new_dueamount.DataValue=(VARValue + paymentamountValue);
}
//alert(parseFloat(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue));

// alert(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue);

// crmForm.all.new_vatgroupvalue.DataValue = resultXml.selectSingleNode('//q1:new_vatvalues') == null ? 0 : parseInt(
// parseFloat(resultXml.selectSingleNode('//q1:new_vatvalues').nodeTypedValue);}

//crmForm.all.new_vatgroupvalue.DataValue=(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue);
///
}
}
}

  • necsa Profile Picture
    3,455 on at
    RE: JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

    Hi,

    You cannot retrieve with this endpoint. This page isn't available after CRM 2011. Hereby again some useful links for you:

    community.dynamics.com/.../447684

    github.com/.../CRMRESTBuilder

    dynamicscrmgirl.wordpress.com/.../

    archive.codeplex.com/

    also, you can use the XRMToolBox web service app my favorite is CRM Rest Builder.

  • jasri Profile Picture
    65 on at
    RE: JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

    Thank you @Guido Preite , Do you know any tool that Convert the script Directly

  • jasri Profile Picture
    65 on at
    RE: JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

    Thank you @Necdet Saritas for your support, I used the tool and the output are identical with the source

    what is the issue , Still using /mscrmservices/2007/CrmService.asmx after converting

    function new_vatgroup_onchange()

    {

    if (Xrm.Page.getAttribute("new_vatgroupid").getValue() != null)

    {

    var vatgroupID= Xrm.Page.getAttribute("new_vatgroupid").getValue()[0].id;

    var authenticationHeader = Xrm.Page.context.getAuthenticationHeader();

    var xml = "<?xml version='1.0' encoding='utf-8'?>"+

    "<soap:Envelope xmlns:soap='">schemas.xmlsoap.org/.../'"

    " xmlns:xsi='">www.w3.org/.../XMLSchema-instance'"

    " xmlns:xsd='">www.w3.org/.../XMLSchema'>"

    authenticationHeader+

    "<soap:Body>"+

    "<Retrieve xmlns='">schemas.microsoft.com/.../WebServices'>"

    "<entityName>new_vatgroup</entityName>"+

    "<id>" + vatgroupID + "</id>"+

    "<columnSet xmlns:q1='schemas.microsoft.com/.../Query' xsi:type='q1:ColumnSet'>"+

    "<q1:Attributes>"+

    "<q1:Attribute>new_vatvalues</q1:Attribute>"+

    "</q1:Attributes>"+

    "</columnSet>"+

    "</Retrieve>"+

    "</soap:Body>"+

    "</soap:Envelope>";

    var xHReq = new ActiveXObject("Msxml2.XMLHTTP");

    xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);

    xHReq.setRequestHeader("SOAPAction","">schemas.microsoft.com/.../Retrieve");

    xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

    xHReq.setRequestHeader("Content-Length", xml.length);

    xHReq.send(xml);

    var resultXml = xHReq.responseXML;

    var errorCount = resultXml.selectNodes('//error').length;

    if (errorCount != 0)

    {

    var msg = resultXml.selectSingleNode('//description').nodeTypedValue;

    alert(msg);

    }

    else

    {

    //filterSubGrid();

    /////

    var paymentamountValue = Xrm.Page.getAttribute("new_paymentamount").getValue();

    //if (optValue == 0) {

    // Xrm.Page.getAttribute("new_vatgroupvalue").setValue(0.06);

    var VARvatgroupvalu = parseFloat(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue)

    Xrm.Page.getAttribute("new_vatgroupvalue").getValue()=(VARvatgroupvalu);

    Xrm.Page.getAttribute("new_vatvalue").getValue()=(0);

    Xrm.Page.getAttribute("new_dueamount").getValue()=(paymentamountValue);

    if (VARvatgroupvalu !=0) {

    var VARValue= (paymentamountValue * VARvatgroupvalu);

    Xrm.Page.getAttribute("new_vatvalue").getValue()=(VARValue);

    Xrm.Page.getAttribute("new_dueamount").getValue()=(VARValue + paymentamountValue);

    }

    //alert(parseFloat(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue));

    // alert(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue);

    // Xrm.Page.getAttribute("new_vatgroupvalue").getValue() = resultXml.selectSingleNode('//q1:new_vatvalues') == null ? 0 : parseInt(

    // parseFloat(resultXml.selectSingleNode('//q1:new_vatvalues').nodeTypedValue);}

    //Xrm.Page.getAttribute("new_vatgroupvalue").getValue()=(resultXml.selectSingleNode("//q1:new_vatvalues").nodeTypedValue);

    ///

    }

    }

    }

  • necsa Profile Picture
    3,455 on at
    RE: JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

    Hi,

    @Guideo Preite has right. Follow his advice and here is a tool to help you convert the old crmForm script to Xrm.Page.

    archive.codeplex.com/

  • Suggested answer
    Guido Preite Profile Picture
    54,077 Moderator on at
    RE: JavaScript Code Upgrade from CRM 2011 to work with CRM 2013 - Service endpoint 2007 and SOAP

    script needs to be updated to use Xrm.Page instead of crmForm

    you need to convert the queries to use 2011 endpoint instead of the SOAP one, you can use CRM REST Builder to assist you with the code.

    hope it helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 91

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans