Determine which Dataverse event triggered a Flow in Power Automate
By Joe GillPublished On 9th September 2020
Using the Common Data Service (Current Environment) connector you can create Power Automate flows that get triggered by an event on a Dataverse table. In this post, we will go through how to identify the Dataverse event that triggered the flow.
Step 1. Create The Flow
When you create the flow you choose a condition or set of conditions that trigger the flow.
Step 2. What Flow does based on the Dataverse trigger
Sometimes you need to vary what the flow does based on the Dataverse trigger that started the flow. There is no obvious way to test which condition triggered the flow. Because of this, I have seen situations on projects where there are lots near-identical flows for create and update. This can obviously lead to maintenance issues. You can however create an expression to examine the SdkMessage attribute in the trigger body of the flow. The SdkMessage contains the name of the event that triggered the flow.
Step 3. Using Expression
You can use the expression in a number of ways such as testing its value as part of a switch or condition control.
Step 4. SdkMessage
You can use SdkMessage in an expression to conditionally set the value of a field based on it’s value e.g. if(equals(triggerBody()?[‘SdkMessage’],’Update’), ‘Updated’, ‘Created’)
Step 5. Testing Value of SdkMessage
If you are testing the value of SdkMessage a number of times in your flow you might be better to create a variable at the start of your flow and use this instead. This will make your flow more readable.