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!
Hi,
Replace alert with console log to see if you are still have issue.
console.log(workflowId + "SENT" + JobId);
Hi
As a suggestion have you checked if you have values in the both variables.
Best regards
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156