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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
ManoVerse Profile Picture

ManoVerse 55 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans