Arbela Blog
Back to Blog Index

How to Trigger a Flow with a Button in Dynamics 365 Customer Engagement

James O'Connor, Senior Consultant, Arbela Techologies

We recently encountered a client request to migrate orders from Dynamics 365 Customer Engagement to Finance and Operations on demand when the end user clicked a ribbon button. We had been leveraging the Prospect to Cash solution’s “Activate” button to simple set the Order to “Active” at which point the PowerApps data integrator would do the heavy lifting. This, however, took too long for certain use cases.

After looking at various options, we decided that leveraging Flow would give us the desired outcome and still leave the process within the D365 ecosystem and allow the customer easy access to modify the solution when needed.

At first, we tried using the Dynamics 365 “When Record is Updated” trigger, but we found the execution to be inconsistent because of the non-specific nature of the update step. So, we started looking at other methods to fire our Flow, and landed on the HTTP Request trigger.

As defined by Microsoft, the HTTP Request trigger is an incoming API call that can trigger the flow. Simply put, this trigger generates a URL the user can then put into whatever function they have to call this Flow on demand.

For our Flow, all we need to get is the GUID value of the order record. So, all we have to do is click “Use sample payload to generate schema,” and add a quick JSON snippet to generate our request schema:

Now that we have our POST URL and schema ready to go, all we have to do is prep it to be added to a JavaScript call within D365 CE. We used Postman as out test bench to test the call and mock up our JavaScript:

Then, all we had to do was add some logic to dynamically pull the Order ID into the function. First, we give the function a name. In this case we named it “callFlow”. Then, we set a up a variable for the order ID using the method. The trouble here is that this returns the GUID with braces, which will break the JSON schema, so we have to add a quick snippet to strip the braces in the variable.

Click here to download the entire guide. Questions? Get in touch with us.