D365: Execute PowerAutomate from Ribbon button using JS

Recently, we had a requirement to execute PowerAutomate on click of a button on Lead record. In this post, we’ll see how to do that.

While creating the PowerAutomate, select the trigger as “When an HTTP request is received” as shown below:

We can pass parameter to the PowerAutomate in JSON format. In this example, we’ll pass Lead Record Id.
Select method as POST.

Just for illustration purpose, let’s select Get record action and for Item Identifier, we can see that the parameter that we passed to the PowerAutomate is available for selection.

Then, let’s save the PowerAutomate to generate the URL.

Once the URL is generated, copy it. We’ll use it in our JS code.

On Lead entity, create a custom ribbon button and execute below JS on click of that button to execute the PowerAutomate.

DXC.SendQuote = function (primaryControl) {   
    var flowUrl = "Copied URL of Power Automate";
    var input = JSON.stringify({
        "LeadId": primaryControl.data.entity.getId().replace("{", "").replace("}", "")
    var req = new XMLHttpRequest();
    req.open("POST", flowUrl, true);
    req.setRequestHeader('Content-Type', 'application/json');

Hope it helps !!


3 thoughts on “D365: Execute PowerAutomate from Ribbon button using JS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.