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