Call Power Automate Flow from Dynamics 365/Model-Driven Apps

| Ijlal Monawwar

Sometimes our requirements are such that we need to be able to call an automated cloud flow from the model driven app to achieve some functionality like sending emails or sending out approvals on teams using the data from the form. In this blog I will be discussing a method by which we can achieve this.

To put it simply, we require a ribbon button on the command bar of the form that takes our data from the form (for e.g., GUID of the record) and then send an http request to the flow’s URL trigger along with the data in the request body.

First, we must create a flow in our solution and set the trigger as “When an http request is received”.

Call Power Automate Flow from Dynamics 365/Model-Driven App
Call Power Automate Flow from Dynamics 365/Model-Driven App

Inside the trigger properties, we select the option to generate schema from sample payload and then we add our JSON with the data we want to pass. In my case, I want to pass a guid which is a string, so my sample payload will look like:

Call Power Automate Flow from Dynamics 365/Model-Driven App

If you want to pass more than one data item, use a comma in between to separate the items. Also set the method to POST, as we are sending data to the endpoint URL. Finally, our trigger will look something like this:

Call Power Automate Flow from Dynamics 365/Model-Driven App

Next, we will be needing a ribbon button on the form which will contain JavaScript code which calls the flow URL and send the guid data to the flow’s trigger. First download XRM toolbox and connect your organization to the ribbon workbench tool.

Call Power Automate Flow from Dynamics 365/Model-Driven App

Now create a javascript web resource in the solution and add this code to it. Add your flow url in the flow url string. Hit save and publish.

Call Power Automate Flow from Dynamics 365/Model-Driven App

Now we go back to ribbon workbench and add a command for our button we recently added on the form. Hit the + icon to add a command and then reference the JavaScript code for the button we’ve just created. Put the logical name of the web resource in the library textbox and put the function name in the Function Name textbox. Click on Add parameter button and pass a CRM parameter for PrimaryControl.

Call Power Automate Flow from Dynamics 365/Model-Driven App

Now on our form, we will see a ribbon button added which will call the flow url and send the guid data of the form record.

Call Power Automate Flow from Dynamics 365/Model-Driven App

Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.


M
Chief Architect, Founder, and CEO - a Microsoft recognized Power Platform solution architect.

About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.


More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting