В настоящее время я использую вызов SOAP для конечной точки 2011, но хочу обновить его до более новой версии Web Api. Я могу «разрешить» дело, но не могу «отменить» его из JavaScript.
Мой текущий код вызова 2011 soap:
// 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>" + formContext.data.entity.getId() + "</a:Id>";
request += "<a:LogicalName>incident</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>" + selectedStatus + "</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>" + selectedStatusReason + "</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>";
//send set state request
$.ajax({
type: "POST",
async: false,
contentType: "text/xml; charset=utf-8",
datatype: "xml",
url: Xrm.Utility.getGlobalContext().getClientUrl() + "/XRMServices/2011/Organization.svc/web",
data: request,
beforeSend: function (xmlHttpRequest) {
xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
},
success: function () {
Alert.hide();
formContext.ui.close();
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
Alert.hide();
Xrm.Navigation.openErrorDialog({ errorCode: "Error in Cancel Ticket request", details: errorThrown }).then(
function () {},
function (error) {
console.log(error);
});
console.log(errorThrown);
}
});