Using Microsoft CRM 4.0
I have a requirement to create a note automatically in a custom entity when an Email is sent from that entity. Am using javascript to do this, below is the code i have used, but is not working for note creation.
Please help.
//get Authenication
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare values for the note
var notetext = "This is a sample note";
var subject = "Test Subject";
var objectId = crmForm.ObjectId;
var objectTypeCode = "10003";
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='http://ift.tt/sVJIaE'" +
" xmlns:xsi='http://ift.tt/ra1lAU'" +
" xmlns:xsd='http://ift.tt/tphNwY'>" +
authenticationHeader +
"<soap:Body>" +
"<Create xmlns='http://ift.tt/19Bb7BX'>" +
"<entity xsi:type='annotation'>" +
"<notetext>" + notetext + "</notetext>" +
"<subject>" + subject + "</subject>" +
"<objectid>" + objectId + "</objectid>" +
"<objecttypecode>" + objectTypeCode + "</objectyypecode>" +
"</entity>" +
"</Create>" +
"</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://ift.tt/R2TpER");
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);
}
Aucun commentaire:
Enregistrer un commentaire