Logic Apps provides a Dataverse trigger that we can use to automatically start the workflow if a new row to a specific table is created or an existing row in a specific table is updated. In a recent project, however, the same Logic Apps worklfow was used to react to changes in both Account and Contact tables. Therefore we were not able to use the out-of-the-box Dataverse trigger. Instead we ended up using Webhooks to trigger the worklflow and this is how it was done.
Create the endpoint
I started by creating a simple Logic Apps workflow with only an HTTP Request trigger.
Use Plugin Registration Tool to register new Webhook and steps
Next you need to use Plugin Registration Tool to register new Webhook. You can install the NuGet package containing the tool by following the instruction given here.
Once installed, open the tool and create a new connection to your target Environment.
Once you have successuflly logged in with the Plugin Registration Tool, choose Register > Register New Web Hook (or press Ctrl+W) as indicated in the picture below.
Next you need to fetch you Logic Apps Http trigger URL via Logic Apps Designer.
You need to remove the query string parameters from the URL and provide them as Properties in your Webhook Registration dialog.
Make sure you choose HttpQueryString as the Authentication method!
Note: Make sure you get the required properties right at the first time! There seems to be a bug in the Plugin Registration Tool that you can’t view (or edit?) the properties after initial registration.
After that you can see the registration under Registered Plugins & Custom Workflow Activities listing.
Now it’s time to register the required steps for the Webhook registration. Click on the new registration item in the list with you mouse secondary button and choose Register New Step from the context menu.
I created steps for both Account and Contact entities and for Create and Update messages for each.
Test it out!
Now that you have the Webhook registration done and appropriate steps configured, it’s time to go ahead and test it! If I create a new contact record in CRM, I can see that my Logic Apps workflow is correctly triggered:
And now I can take a look at payload of the trigger data and proceed modifying the workflow according to business needs.