Why does the WEB API CloseIncident Action cancel the activities and does not check if the case has been saved? I was hoping to get those checks as well.
However ... since I like this action ... I'm still trying to find a way to use it, but first of all I need a way to check for open activities and if mandatory fields are filled in.
I tried to use the IsValidStateTransition Function since, as far as I understood, for the corresponding organization service IsValidStateTransitionRequest an exception is thrown if an incident (case) has open activities but I can't bring it to work!!!
Here what I've tried:
var parameters = {};
parameters.Entity = {'@odata.id':'incidents(47E71C9D-7902-E711-80FA-5065F38A1B01)'};
parameters.NewState = "Resolved";
parameters.NewStatus = 922210005;
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/IsValidStateTransition()", false);
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 === 200) {
var results = JSON.parse(this.response);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(parameters));
but I get "Internal Server Error"
then I tried following:
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/IsValidStateTransition(Entity=@ent,NewState='Resolved',NewStatus=922210005)?@ent={'@odata.id':'incidents(47E71C9D-7902-E711-80FA-5065F38A1B01)'}", false);
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 === 200) {
var results = JSON.parse(this.response);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify());
but it still doesn't want to work
Any help is highly appreciated!
*This post is locked for comments