Monthly Archives: August 2015

Dynamics CRM 2015 : some simple javascript function

// JavaScript CRM 2015 code
if (typeof (ZZSOFT) == “undefined”)
{ ZZSOFT = { __namespace: true }; }
if (typeof (ZZSOFT.CRM) == “undefined”)
{ ZZSOFT.CRM = { __namespace: true }; }
ZZSOFT.CRM.Common = {
//
// Disable all control inside the form
//
disableAllControls: function () {
  Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
    ZZSOFT.CRM.Common.disableCtrl(attribute.getName());
  });
},
//
// Enable all control inside the form
//
enableAllControlss: function () {
  Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
    ZZSOFT.CRM.Common.enableCtrl(attribute.getName());
  });
},
//
// Disable e single control on form and business process bar if it is present
// ctrlName = Control name
disableCtrl: function (ctrlName) {
  var c = Xrm.Page.getControl(ctrlName);
  if (c != null) {
    c.setDisabled(true);
  }
  var hpc = Xrm.Page.getControl(“header_process_” + ctrlName);
  if (hpc != null) {
    hpc.setDisabled(true);
  }
},
//
// Enable single control on form and business process bar if it is present
// ctrlName = Control name
enableCtrl: function (ctrlName) {
  var c = Xrm.Page.getControl(ctrlName);
  if (c != null) {
    c.setDisabled(false);
  }
  var hpc = Xrm.Page.getControl(“header_process_” + ctrlName);
  if (hpc != null) {
    hpc.setDisabled(false);
  }
},
//
// Hide single control on form and business process bar if it is present
// ctrlName = Control name
hideCtrl: function (ctrlName) {
  var c = Xrm.Page.getControl(ctrlName);
  if (c != null) {
    c.setVisible(false);
  }
  var hpc = Xrm.Page.getControl(“header_process_” + ctrlName);
  if (hpc != null) {
    hpc.setVisible(false);
  }
},
//
// Show single control on form and business process bar if it is present
// ctrlName = Control name
showCtrl: function (ctrlName) {
  var c = Xrm.Page.getControl(ctrlName);
  if (c != null) {
    c.setVisible(true);
  }
  var hpc = Xrm.Page.getControl(“header_process_” + ctrlName);
  if (hpc != null) {
    hpc.setVisible(true);
  }
},
//
// Hide section
// sectionName = Name of the section
hideSection: function (sectionName) {
  var tabs = Xrm.Page.ui.tabs.get();
  for (var i in tabs) {
    var tab = tabs[i];
    tab.sections.forEach(function (section, index) {
      if (section.getName() == sectionName) {
        section.setVisible(false);
      }
    });
  }
},
//
// Show section
// sectionName = Name of the section
showSection: function (sectionName) {
  var tabs = Xrm.Page.ui.tabs.get();
  for (var i in tabs) {
    var tab = tabs[i];
    tab.sections.forEach(function (section, index) {
      if (section.getName() == sectionName) {
        section.setVisible(true);
      }
    });
  }
},
//
// Hide tab
// tabName= Name of the tab
hideTab: function (tabName) {
  var tabs = Xrm.Page.ui.tabs.get();
  for (var i in tabs) {
    var tab = tabs[i];
    if (tab.getName() == tabName) {
      tab.setVisible(false);
    }
  }
},
//
// Show tab
// tabName= Name of the tab
showTab: function (tabName) {
  var tabs = Xrm.Page.ui.tabs.get();
  for (var i in tabs) {
    var tab = tabs[i];
    if (tab.getName() == tabName) {
      tab.setVisible(true);
    }
  }
},
__namespace: true
}

Microsoft Dynamics CRM 2015 and javascript

During my last Dynamics CRM 2015 project I have made many customizations using JavaScript. I have found some difficult retrieve and discover information regarding the different “SOAP” messages used by the Organization Services. I have attached to this post a modified file of the Microsoft SDK with more message and function. Inside the namespace “SDK.SOAPSamples” I have added three synchronous call to the organization  service of Dynamics CRM 2015.

  • SDK.SOAPSamples.assignEntitySync: function (recordId, recordType, newOwnerId)Assign the record identify by recordId (the guid of the record) and recordType (logicalname of the entity) at the user with the newOwnerId (the guid of the user)
  • SDK.SOAPSamples.changeEntityStateSync: function (recordId, recordType, stateCode, statusCode)Change the Statecode (int value) and Statuscode (int value) of the record identify by recordId (the guid of the record) and recordType (logicalname of the entity)
  • SDK.SOAPSamples.loseOpportunityRequest: function (recordId, comment) Close the opportunity identified by recordId (the guid of the opportunity) and add the comment (a string)
  • SDK.SOAPSamples.closeQuoteSync: function (quoteId, statusCode, closeNote)Close the quote identified by quoteId (the guid of the quote) with the statusCode (int value) and add the comment (closeNote is string)

ATTENTION: The function need to be correct for a production environment. For example if someone use a comment like “Hello ‘ word “” probably the system return an error.
PS. I’m unable attach the script. Send me a message and I send you the script. In the future I post it in OneDrive or DropBox
SDK.SOAPSamples = {
_getClientUrl: function () {
///<summary>
/// Returns the URL for the SOAP endpoint using the context information available in the form
/// or HTML Web resource.
///</summary
var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
var clientUrl = "";
if (typeof GetGlobalContext == "function") {
var context = GetGlobalContext();
clientUrl = context.getClientUrl();
}
else {
if (typeof Xrm.Page.context == "object") {
clientUrl = Xrm.Page.context.getClientUrl();
}
else { throw new Error("Unable to access the server URL"); }
}

return clientUrl + OrgServicePath;
},
assignRequest: function (Assignee, Target, Type, successCallback, errorCallback) {
///<summary>
/// Sends the Assign Request
///</summary>
this._parameterCheck(Assignee, "GUID", "The SDK.SOAPSamples.assignRequest method Assignee parameter must be a string Representing a GUID value.");
///<param name="Assignee" Type="String">
/// The GUID representing the System user that the record will be assigned to.
///</param>
this._parameterCheck(Target, "GUID", "The SDK.SOAPSamples.assignRequest method Target parameter must be a string Representing a GUID value.");
///<param name="Target" Type="String">
/// The GUID representing the user-owned entity record that will be assigne to the Assignee.
///</param>
this._parameterCheck(Type, "String", "The SDK.SOAPSamples.assignRequest method Type parameter must be a string value.");
Type = Type.toLowerCase();
///<param name="Type" Type="String">
/// The Logical name of the user-owned entity. For example, 'account'.
///</param>
if (successCallback != null)
this._parameterCheck(successCallback, "Function", "The SDK.SOAPSamples.assignRequest method successCallback parameter must be a function.");
///<param name="successCallback" Type="Function">
/// The function to perform when an successfult response is returned.
///</param>
this._parameterCheck(errorCallback, "Function", "The SDK.SOAPSamples.assignRequest method errorCallback parameter must be a function.");
///<param name="errorCallback" Type="Function">
/// The function to perform when an error is returned.
///</param>
//The request is simply the soap envelope captured by the SOAPLogger with variables added for the
// values passed. All quotations must be escaped to create valid JScript strings.
var request = [];

request.push("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
request.push("<s:Body>");
request.push("<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\"");
request.push(" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">");
request.push("<request i:type=\"b:AssignRequest\"");
request.push(" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"");
request.push(" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">");
request.push("<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Target</c:key>");
request.push("<c:value i:type=\"a:EntityReference\">");
request.push("<a:Id>" + this._xmlEncode(Target) + "</a:Id>");
request.push("<a:LogicalName>" + this._xmlEncode(Type) + "</a:LogicalName>");
request.push("<a:Name i:nil=\"true\" />");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Assignee</c:key>");
request.push("<c:value i:type=\"a:EntityReference\">");
request.push("<a:Id>" + this._xmlEncode(Assignee) + "</a:Id>");
request.push("<a:LogicalName>systemuser</a:LogicalName>");
request.push("<a:Name i:nil=\"true\" />");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("</a:Parameters>");
request.push("<a:RequestId i:nil=\"true\" />");
request.push("<a:RequestName>Assign</a:RequestName>");
request.push("</request>");
request.push("</Execute>");
request.push("</s:Body>");
request.push("</s:Envelope>");

var req = new XMLHttpRequest();
req.open("POST", SDK.SOAPSamples._getClientUrl(), true)
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
req.onreadystatechange = function () { SDK.SOAPSamples.assignResponse(req, successCallback, errorCallback); };
req.send(request.join(""));

},
assignResponse: function (req, successCallback, errorCallback) {
///<summary>
/// Recieves the assign response
///</summary>
///<param name="req" Type="XMLHttpRequest">
/// The XMLHttpRequest response
///</param>
///<param name="successCallback" Type="Function">
/// The function to perform when an successfult response is returned.
/// For this message no data is returned so a success callback is not really necessary.
///</param>
///<param name="errorCallback" Type="Function">
/// The function to perform when an error is returned.
/// This function accepts a JScript error returned by the _getError function
///</param>
if (req.readyState == 4) {
req.onreadystatechange = null; //avoids memory leaks
if (req.status == 200) {
if (successCallback != null)
{ successCallback(); }
}
else {
errorCallback(SDK.SOAPSamples._getError(req.responseXML));
}
}
},
_getError: function (faultXml) {
///<summary>
/// Parses the WCF fault returned in the event of an error.
///</summary>
///<param name="faultXml" Type="XML">
/// The responseXML property of the XMLHttpRequest response.
///</param>
var errorMessage = "Unknown Error (Unable to parse the fault)";
if (typeof faultXml == "object") {
try {
var bodyNode = faultXml.firstChild.firstChild;
//Retrieve the fault node
for (var i = 0; i < bodyNode.childNodes.length; i++) {
var node = bodyNode.childNodes[i];

//NOTE: This comparison does not handle the case where the XML namespace changes
if ("s:Fault" == node.nodeName) {
for (var j = 0; j < node.childNodes.length; j++) {
var faultStringNode = node.childNodes[j];
if ("faultstring" == faultStringNode.nodeName) {
errorMessage = faultStringNode.textContent;
break;
}
}
break;
}
}
}
catch (e) { };
}
return new Error(errorMessage);
},
_xmlEncode: function (strInput) {
var c;
var XmlEncode = '';

if (strInput == null) {
return null;
}
if (strInput == '') {
return '';
}

for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);

if (((c > 96) && (c < 123)) ||
((c > 64) && (c < 91)) ||
(c == 32) ||
((c > 47) && (c < 58)) ||
(c == 46) ||
(c == 44) ||
(c == 45) ||
(c == 95)) {
XmlEncode = XmlEncode + String.fromCharCode(c);
}
else {
XmlEncode = XmlEncode + '&#' + c + ';';
}
}

return XmlEncode;
},
_parameterCheck: function (parameter, type, errorMessage) {
switch (type) {
case "String":
if (typeof parameter != "string") {
throw new Error(errorMessage);
}
break;
case "Function":
if (typeof parameter != "function") {
throw new Error(errorMessage);
}
break;
case "EntityFilters":
var found = false;
for (x in this.EntityFilters) {
if (this.EntityFilters[x] == parameter) {
found = true;
break;
}
}
if (!found) {
throw new Error(errorMessage);
}
break;
case "Boolean":
if (typeof parameter != "boolean") {
throw new Error(errorMessage);
}
break;
case "GUID":
var re = new RegExp("[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}");
if (!(typeof parameter == "string" && re.test(parameter))) {
throw new Error(errorMessage);
}

break;
default:
throw new Error("An invalid type parameter value was passed to the SDK.MetaData._parameterCheck function.");
break;
}
},
assignEntitySync: function (recordId, recordType, newOwnerId)
{
///<summary>
/// Sends the Assign Request
///</summary>
this._parameterCheck(recordId, "GUID", "The SDK.SOAPSamples.assignRequest method Assignee parameter must be a string Representing a GUID value.");
///<param name="recordId" Type="String">
/// The GUID representing the System user that the record will be assigned to.
///</param>
this._parameterCheck(newOwnerId, "GUID", "The SDK.SOAPSamples.assignRequest method Target parameter must be a string Representing a GUID value.");
///<param name="newOwnerId" Type="String">
/// The GUID representing the user-owned entity record that will be assigne to the Assignee.
///</param>
this._parameterCheck(recordType, "String", "The SDK.SOAPSamples.assignRequest method Type parameter must be a string value.");
recordType = recordType.toLowerCase();
///<param name="recordType" Type="String">
/// The Logical name of the user-owned entity. For example, 'account'.
///</param>
var request = [];

request.push("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
request.push("<s:Body>");
request.push("<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\"");
request.push(" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">");
request.push("<request i:type=\"b:AssignRequest\"");
request.push(" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"");
request.push(" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">");
request.push("<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Target</c:key>");
request.push("<c:value i:type=\"a:EntityReference\">");
request.push("<a:Id>" + this._xmlEncode(recordId) + "</a:Id>");
request.push("<a:LogicalName>" + this._xmlEncode(recordType) + "</a:LogicalName>");
request.push("<a:Name i:nil=\"true\" />");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Assignee</c:key>");
request.push("<c:value i:type=\"a:EntityReference\">");
request.push("<a:Id>" + this._xmlEncode(newOwnerId) + "</a:Id>");
request.push("<a:LogicalName>systemuser</a:LogicalName>");
request.push("<a:Name i:nil=\"true\" />");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("</a:Parameters>");
request.push("<a:RequestId i:nil=\"true\" />");
request.push("<a:RequestName>Assign</a:RequestName>");
request.push("</request>");
request.push("</Execute>");
request.push("</s:Body>");
request.push("</s:Envelope>");
var req = new XMLHttpRequest();
req.open("POST", SDK.SOAPSamples._getClientUrl(), false);
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
//req.onreadystatechange = function () { SDK.SOAPSamples.assignResponse(req, successCallback, errorCallback); };
req.send(request.join(""));
if (req.status != 200) {
SDK.SOAPSamples._getError(req.responseXML);
}
},
changeEntityStateSync: function (recordId, recordType, stateCode, statusCode)
{

// create the SetState request
var request = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
request += "<s:Body>";
request += "<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
request += "<request i:type=\"b:SetStateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
request += "<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
request += "<a:KeyValuePairOfstringanyType>";
request += "<c:key>EntityMoniker</c:key>";
request += "<c:value i:type=\"a:EntityReference\">";
request += "<a:Id>" + recordId + "</a:Id>";
request += "<a:LogicalName>" + recordType + "</a:LogicalName>";
request += "<a:Name i:nil=\"true\" />";
request += "</c:value>";
request += "</a:KeyValuePairOfstringanyType>";
request += "<a:KeyValuePairOfstringanyType>";
request += "<c:key>State</c:key>";
request += "<c:value i:type=\"a:OptionSetValue\">";
request += "<a:Value>" + stateCode + "</a:Value>";
request += "</c:value>";
request += "</a:KeyValuePairOfstringanyType>";
request += "<a:KeyValuePairOfstringanyType>";
request += "<c:key>Status</c:key>";
request += "<c:value i:type=\"a:OptionSetValue\">";
request += "<a:Value>" + statusCode + "</a:Value>";
request += "</c:value>";
request += "</a:KeyValuePairOfstringanyType>";
request += "</a:Parameters>";
request += "<a:RequestId i:nil=\"true\" />";
request += "<a:RequestName>SetState</a:RequestName>";
request += "</request>";
request += "</Execute>";
request += "</s:Body>";
request += "</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", SDK.SOAPSamples._getClientUrl(), false);
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
//req.onreadystatechange = function () { SDK.SOAPSamples.assignResponse(req, successCallback, errorCallback); };
req.send(request);
if (req.status != 200) {

SDK.SOAPSamples._getError(req.responseXML);
}

},
loseOpportunityRequest: function (recordId, comment) {
var requestMain = ""
requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
requestMain += " <s:Body>";
requestMain += " <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
requestMain += " <request i:type=\"b:LoseOpportunityRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
requestMain += " <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
requestMain += " <a:KeyValuePairOfstringanyType>";
requestMain += " <c:key>OpportunityClose</c:key>";
requestMain += " <c:value i:type=\"a:Entity\">";
requestMain += " <a:Attributes>";
requestMain += " <a:KeyValuePairOfstringanyType>";
requestMain += " <c:key>opportunityid</c:key>";
requestMain += " <c:value i:type=\"a:EntityReference\">";
requestMain += " <a:Id>" +recordId + "</a:Id>";
requestMain += " <a:LogicalName>opportunity</a:LogicalName>";
requestMain += " <a:Name i:nil=\"true\" />";
requestMain += " </c:value>";
requestMain += " </a:KeyValuePairOfstringanyType>";
requestMain += " <a:KeyValuePairOfstringanyType>";
requestMain += " <c:key>subject</c:key>";
requestMain += " <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">" + comment + "</c:value>";
requestMain += " </a:KeyValuePairOfstringanyType>";
requestMain += " </a:Attributes>";
requestMain += " <a:EntityState i:nil=\"true\" />";
requestMain += " <a:FormattedValues />";
requestMain += " <a:Id>00000000-0000-0000-0000-000000000000</a:Id>";
requestMain += " <a:LogicalName>opportunityclose</a:LogicalName>";
requestMain += " <a:RelatedEntities />";
requestMain += " </c:value>";
requestMain += " </a:KeyValuePairOfstringanyType>";
requestMain += " <a:KeyValuePairOfstringanyType>";
requestMain += " <c:key>Status</c:key>";
requestMain += " <c:value i:type=\"a:OptionSetValue\">";
requestMain += " <a:Value>4</a:Value>";
requestMain += " </c:value>";
requestMain += " </a:KeyValuePairOfstringanyType>";
requestMain += " </a:Parameters>";
requestMain += " <a:RequestId i:nil=\"true\" />";
requestMain += " <a:RequestName>LoseOpportunity</a:RequestName>";
requestMain += " </request>";
requestMain += " </Execute>";
requestMain += " </s:Body>";
requestMain += "</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", SDK.SOAPSamples._getClientUrl(), false);
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
req.send(requestMain);
if (req.status != 200) {
SDK.SOAPSamples._getError(req.responseXML);
} else {
return req.responseXML;
}
},
closeQuoteSync: function (quoteId, statusCode, closeNote) {
var reqMessage = ""
reqMessage += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
reqMessage += " <s:Body>";
reqMessage += " <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
reqMessage += " <request i:type=\"b:CloseQuoteRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
reqMessage += " <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
reqMessage += " <a:KeyValuePairOfstringanyType>";
reqMessage += " <c:key>QuoteClose</c:key>";
reqMessage += " <c:value i:type=\"a:Entity\">";
reqMessage += " <a:Attributes>";
reqMessage += " <a:KeyValuePairOfstringanyType>";
reqMessage += " <c:key>quoteid</c:key>";
reqMessage += " <c:value i:type=\"a:EntityReference\">";
reqMessage += " <a:Id>" + quoteId + "</a:Id>";
reqMessage += " <a:LogicalName>quote</a:LogicalName>";
reqMessage += " <a:Name i:nil=\"true\" />";
reqMessage += " </c:value>";
reqMessage += " </a:KeyValuePairOfstringanyType>";
reqMessage += " <a:KeyValuePairOfstringanyType>";
reqMessage += " <c:key>subject</c:key>";
reqMessage += " <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">" + closeNote+ "</c:value>";
reqMessage += " </a:KeyValuePairOfstringanyType>";
reqMessage += " </a:Attributes>";
reqMessage += " <a:EntityState i:nil=\"true\" />";
reqMessage += " <a:FormattedValues />";
reqMessage += " <a:Id>00000000-0000-0000-0000-000000000000</a:Id>";
reqMessage += " <a:LogicalName>quoteclose</a:LogicalName>";
reqMessage += " <a:RelatedEntities />";
reqMessage += " </c:value>";
reqMessage += " </a:KeyValuePairOfstringanyType>";
reqMessage += " <a:KeyValuePairOfstringanyType>";
reqMessage += " <c:key>Status</c:key>";
reqMessage += " <c:value i:type=\"a:OptionSetValue\">";
reqMessage += " <a:Value>" + statusCode + "</a:Value>";
reqMessage += " </c:value>";
reqMessage += " </a:KeyValuePairOfstringanyType>";
reqMessage += " </a:Parameters>";
reqMessage += " <a:RequestId i:nil=\"true\" />";
reqMessage += " <a:RequestName>CloseQuote</a:RequestName>";
reqMessage += " </request>";
reqMessage += " </Execute>";
reqMessage += " </s:Body>";
reqMessage += "</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", SDK.SOAPSamples._getClientUrl(), false);
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
req.send(reqMessage);
if (req.status != 200) {
SDK.SOAPSamples._getError(req.responseXML);
}
},
__namespace: true
};