Hello,
We are having an issue where we have created JavaScript to run a workflow through a function. We had created alerts throughout the code while writing and testing. Everything was working great and the workflows were being executed. However, when we commented out our alert, the execute workflow stopped working. Please help:
function RunWorkflow(workflowId, JobId) {
var clientUrl = "">http://ct-d365sb/CTi";
var data = {
"EntityId":JobId
};
try {
var req = new XMLHttpRequest();
req.open("POST", clientUrl + "/api/data/v9.0/workflows(" + workflowId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 200) {
//var result = JSON.parse(this.response);
} else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send(JSON.stringify(data));
alert(workflowId + " SENT " + JobId);
}
catch (e) {
throw (e);
}
}
Anyone have any suggestions? The alert causing the problem is the alert right below the "req.send(JSON.stringify(data));"
Thank you in advance! This has been driving us crazy for 2 days!