Tuesday, November 30, 2010

Update Related Contact Fields

var parentCustomer = crmForm.all.parentcustomerid.DataValue;
var contactId = parentCustomer[0].id;
var IsQualifierOwnerId = crmForm.all.ctca_isqualifierownerid.DataValue;
var newIsQualifierOwnerId = IsQualifierOwnerId[0].id;
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = ""+
" " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
""+
""+
""+
"" + newIsQualifierOwnerId + "" +
""+contactId+""+
"
"+
"
"+
"
"+
"
";
// 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);