Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

How to run asynchronous workflow through Javascript and get its status whether that workflow succeded or Failed?

$
0
0

Hello All,

I am using the code below  to run asynchronous workflow , it runs the workflow but always give success even if the workflow failed due to errors.I want to get that status whether they are succedded or failed and I have tried making true to false in the below code but still not working.Can anyone help me what should i do please or should i follow another method please let me know asap. It is urgent?

var entity = {
"EntityId": reportingRecords[j].id
};
var WorkflowId = "A86494D4-63E8-4A32-B2BB-B0D0EAB26652";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/workflows(" + WorkflowId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", 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 === 200) {
console.log("Success");
} else {
Xrm.Utility.alertDialog(this.statusText);
console.log("Failed");
}
}
};
req.send(JSON.stringify(entity));

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>