web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Commenting out alert breaks code

(0) ShareShare
ReportReport
Posted on by 212

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!

I have the same question (0)
  • CarlosDuran Profile Picture
    5 on at

    Hi

    As a suggestion have you checked if you have values in the both variables.

    Best regards

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Replace alert with console log to see if you are still have issue.

    console.log(workflowId + "SENT" + JobId);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans