I'm trying to cancel an order programmatically using the CancelSalesOrder action. I've tried every which way syntax but keep getting either a 400 (bad request) or 500 (server error).
Here is the syntax that gives me error 500, what am I doing wrong?
var parameters = {};
var orderclose = {};
orderclose.salesorderid = "4210B4C1-C1F3-4460-8615-1BE68FDFCC40";
orderclose["@odata.type"] = "Microsoft.Dynamics.CRM.salesorder";
parameters.OrderClose = orderclose;
parameters.Status = 100000017;
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/CancelSalesOrder", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(parameters));
As a secondary question why does the cancel order dialog (called by the Cancel button on the Order form ribbon) have a description and cancel date value that a user can provide? Where is description and cancel date stored? Why aren't these fields a part of the API?
*This post is locked for comments
I have the same question (0)