web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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);
///
}
}
}

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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

  • necsa Profile Picture
    3,455 on at

    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/

  • jasri Profile Picture
    65 on at

    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);

    ///

    }

    }

    }

  • jasri Profile Picture
    65 on at

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

  • necsa Profile Picture
    3,455 on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 107 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 92

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans