Call Power Automate or Microsoft Flow from JavaScript – Dynamics 365 CE

Hi Everyone,

We all know how Power Automate or Microsoft Flows are changing the way we design the things in Dynamics 365 CE. Recently, we got a requirement to call Microsoft Flow from a button click on Dynamics 365. Here is the way we did using JavaScript.

Let’s create a flow as below.

1) Take the trigger as HTTP Request received.


2) Generate Schema accordingly to your input, I just have AccountID as an Input so taken JSON as below to generate schema and declare the method as POST.
{“AccountId”: “abc”}


3) I just added one step of Variable as once the flows is triggered from the JavaScript, we can add the steps as per our requirement.


4) Save the flow and get the URL from HTTP Trigger (first step)


5) Here is the JavaScript code for calling flow.

function callFlowFromJavaScript() {
    var flowUrl = "FLOW URL";
    var input = JSON.stringify({
        "AccountId": "475b158c-541c-e511-80d3-3863bb347ba8"
    });
    var req = new XMLHttpRequest();
    req.open("POST", flowUrl, true);
    req.setRequestHeader('Content-Type', 'application/json');
    req.send(input);
}

To Configure Flow URL in a best way, you can read this Post.

Hope this helps.


Happy 365’ing
Gopinath.

One thought on “Call Power Automate or Microsoft Flow from JavaScript – Dynamics 365 CE

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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s