| 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”.
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:
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:
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.
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.
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.
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.
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.