Introduction:
Microsoft Flow is a Microsoft service which works as middle ware in different platforms and allows to perform many operations in Dynamics 365 CRM that is similar to workflows.
In this blog, we will see how we can run the Microsoft Flow directly from the custom button of Dynamics 365 CRM.
For example, we have a requirement to run the Microsoft Flow in custom button directly or after doing any operations.
In order to achieve this, follow the steps given below:
Step 1: – Create Microsoft instant Flow and select ‘When an http request is received’.
Step 2: – After creating the Flow, set a unique name for the current Flow. Next, add JSON schema as per the data you want to receive or generate by clicking on use sample payload to generate schema.
In this blog, we will be passing JSON object to the request as given below:
Step 3: – Add composer to store data that has passed to the request from Dynamics 365 CRM.
Now save the Flow and copy URL of http request which is going to be used in script on custom ribbon button.
Step 4: – Create a script file and add the JavaScript function for custom button.
Step 5:- On click of button, script function will be called and http request will be executed. To run Microsoft Flow the process is as follows:
- Create a JSON object as data and make sure to provide the same property as we have in Microsoft Flow.
- Set the http request URL which we have copied in step 3 from Flow.
- And once we get the success status from the request we will be showing a popup message or you can have your own logic as per your requirement.
Step 6: – Add custom button on the entity on which you want to run the Flow. We have added a custom button on account entity by using ribbon workbench and on click event we have selected the script and script function created in steps 4 & 5 as shown in the following screenshot:
Step 7: – Now go to the entity and click on the custom button. Here is our Flow which ran successfully.
Conclusion:
Thus, with ‘When http request receive’ connector we can run Microsoft Flow by executing the http request from custom ribbon button.