Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Update lookup field of Contact using SOAP Javascript

$
0
0

Hello Experts, i am trying to update the ParentCustomerId (lookup) in Contact entity but the field is not updating

I am doing like below Please suggest where i am wrong.

typeName="contact";

 var xml = "<?xml version='1.0' encoding='utf-8'?>" +
    "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
    " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
    " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
    authenticationHeader +
    "<soap:Body>" +
    "<Update xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
    "<entity xsi:type='" + typeName + "'>" +
    "<parentcustomerid>" + attributeValue + "</parentcustomerid>" +
    "<contactid>" + recordId + "</contactid>" +     
    "</entity>" +
    "</Update>" +
    "</soap:Body>" +
                "</soap:Envelope>";
                // Prepare the xmlHttpObject and send the request.
                var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
                xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
                xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Update");
                xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                xHReq.setRequestHeader("Content-Length", xml.length);
                xHReq.send(xml);
                // Capture the result
                var resultXml = xHReq.responseXML;

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

Thank you


saroj


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>