Take action based on value in a Dataverse column using Power Automate

When a record in Dataverse changes the updated value can represent a state change within a business process that needs to execute further action. Consider the Tasks table. If the Activity Status column value changes to “Completed” then notify the user who submitted the issue. In Power Automate we can support this type of process using the Dataverse When a row is added, modified or deleted trigger and specifically the Modified change type that can target specific table columns and values. In this blog post we will take a closer look at the trigger options and show how you can get started with creating Flows that take action based on a value change within a Dataverse table.

The When a row is added, modified or deleted trigger is available when creating an automated cloud Flow and includes the following options:

  • Change type choices to scope the Flow execution to a particular action like add, modify, and delete.
Change type choices to scope the Flow execution to a particular action like add, modify, and delete
  • Table name choices for all of the tables available to you within your Dataverse environment.
Table name choices for all of the tables available to you within your Dataverse environment.
  • Scope choices to limit the Flow execution based on the records selected ownership.
    • Business Unit: Flow will only execute if record is owned by the users in the same Business Unit.
    • Organization: Flow will execute regardless of ownership by any users in the same Organization.
    • Parent: Child business unit: Flow will only execute if record is owned by the users in the same Business Unit or a Child Business Unit.
    • User: Flow will only execute if the record is owned by the user
Scope choices to limit the Flow execution based on the records selected ownership.
  • Select columns will limit the Flow execution to the logical column names entered. Multiple columns are allowed and should be separated by a comma.
Select columns will limit the Flow execution to the logical column names entered.
  • Filter rows will limit the Flow execution to only those records meeting OData filter query.
Filter rows will limit the Flow execution to only those records meeting OData filter query
  • Delay until postpones the Flow execution to the time delay specified. Expressions are not supported. Specify a date column from the existing record.
  • Run as sets the users context for the Flow connections during execution.
    • Flow owner: User listed as the Flow owner.
    • Modifying user: User triggering the Flow.
    • Row owner: User listed as the records owner.
Run as sets the users context for the Flow connections during execution

Create Flow using the When a row is added, modified or deleted trigger

Create a new automated cloud flow using the Dataverse When an action is performed trigger.

Dataverse When an action is performed trigger

In our example, we are triggering off of the Tasks table when the Activity Status choice column has been set to “Completed”.

Tasks table when the Activity Status choice column has been set to “Completed”

Before configuring the trigger, get the Logical name (A) column name and the desired Choices Value (B) from Dataverse > Tables > Tasks > Columns > Edit column.

the Logical name (A) column name and the desired Choices Value (B) from Dataverse

Set the When an action is performed trigger as follows:

  • Change type to “Modified”
  • Table name to “Tasks”
  • Scope to “Organization”
  • Select columns to “statecode”
  • Filter rows to “statecode eq 1”
 When an action is performed settings

With this configuration the Flow will execute if anyone sets the Activity Status column to “Complete”. The rest of my demo build includes steps to lookup record owner and record modifier information.

Add a Dataverse Get a row by ID action and set:

  • Table name to “Users”
  • Row ID to Dynamic Value “Owner (Value)” from the trigger
Dataverse Get a row by ID action

Add a Dataverse Get a row by ID action and set:

  • Table name to “Users”
  • Row ID to Dynamic Value “Modified By (Value)” from the trigger
Additional Dataverse Get a row by ID

Add an Outlook Send an email (V2) action and set:

  • To to Dynamic Value “Primary Email” from the “Get a row by ID” owner action
  • Subject to Dynamic Value “Subject” from the trigger
  • Body to any static or dynamic message of your choosing.
 Outlook Send an email (V2) action

My completed Flow looks like the image below.

My complete Flow

To test your Flow, create a new Task in Dataverse and then update the Activity Status to “Complete”. If all goes well the Flow will execute and you will receive the email notification. This is a simple Flow pattern that is useful for triggering further action as a result of state changes like sending notifications, updating related records and starting sub-processes.

Output email message

Thanks for reading!

NY

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s