Exercise - Build a flow that runs when an event in Dynamics 365 occurs

Completed

You can create flows that start when an event occurs in Microsoft Dataverse or some other service. These flows then perform an action in that service.

In Power Automate, you can set up automated workflows between your favorite apps and services to sync files, get notifications, collect data, and more.

In this unit, we look to build two flows:

  • The first flow creates a task in Microsoft Dataverse when a new Account is created.
  • The second flow copies a list item to the Planner when a task is created in Microsoft Dataverse.

Here are some other examples of flows that you can create by using Microsoft Dataverse:

  • Create a list item in Microsoft SharePoint when an object is created in Microsoft Dataverse.
  • Create Microsoft Dataverse account records from a Microsoft Excel table.

Prerequisites

Important

To invoke a flow trigger, the Microsoft Dataverse customer engagement table that's used with the flow must have change tracking turned on. For more about how to turn on change tracking, see Enable change tracking to control data synchronization.

Example one: Create a task from a new account

This example shows how to create a new row in the Dataverse Tasks table whenever an account is added to the Dataverse Accounts table. Both the Accounts and Tasks tables are part of the Common Data Model and are available in all Microsoft Dataverse environments.

  1. Sign in to Power Automate using your organizational account then select the environment for the flow.

  2. In the left pane, select My flows.

  3. Select New flow, and then select Automated cloud flow.

  4. Type in a name for the flow under Flow name. For this example, type Create a task when an account is created for the flow name.

  5. In the list of flow triggers, enter Microsoft Dataverse in the search all triggers field and then select Microsoft Dataverse - When a row is added, modified, or deleted.

  6. Select Create. If prompted to sign in to Dataverse, do so.

    Screenshot of the Create a new flow page with the trigger set to When a row is added, modified or deleted.

  7. From the canvas pane, select the trigger action When a row is added, modified, or deleted to open it in the action configuration pane.

  8. Select Added for Change type, select Accounts for Table name.

  9. For the Scope, select Organization

    Tip

    The Dataverse trigger requires a Scope to be specified.The scope determines whether the flow runs when a user within a business unit creates a new record, or if any user in the organization creates a new record.

    Next, we add another action using Copilot.

  10. In the Copilot pane on the right, type in When a new row is added to a Dataverse table, add a new row to another Dataverse table and press ENTER.

    Screenshot of the Copilot pane with the When a new row is added to a Dataverse table, add a new row to another Dataverse table option selected.

  11. Copilot expands the flow and adds the action Add a new row.

    Note

    Copilot may give you an "Invalid parameters" warning in your flow trigger as it updates the flow. If that happens, return to your flow trigger and update the required parameters before continuing.

  12. Select the action Add a new row to configure the properties. The action configuration pane on the left pops out.

  13. In the Table Name field, find/select the Tasks table.

  14. More fields appear under the table selection. Select the Subject field and then the dynamic content icon (it's in the shape of a lightening bolt) to choose fields from the previous steps.

    For this unit, select Account name.

    Screenshot of Create a new record with the Subject field set to the dynamic content Full name.

  15. Select Save from the right side of the command bar to save the flow.

Now when a new row is added to the Accounts table, Power Automate creates a new row in the Tasks table and the Subject of the task is the name of the new account.

Example: Create a planner task from a Microsoft Dataverse task

This example shows how to create a task in Microsoft Planner whenever a task is created in Microsoft Dataverse. Planner is a service that you can use to create to-do lists, add reminders, and track errands. To complete the example, you need to create a plan in Planner.

  1. Return to make.powerautomate.com using your organizational account then select the environment for the flow.

  2. In the left pane, select My flows.

  3. Select + New flow, and then select Automated cloud flow.

  4. Type in a name for the flow under Flow name. For this example, type Create a Planner task when a Dataverse task is created for the flow name.

  5. Type in Dataverse in the search all triggers field and then select Microsoft Dataverse - When a row is added, modified, or deleted.

  6. Select Create.

  7. The new flow opens in Power Automate Copilot designer.

  8. Select the trigger When a row is added, modified, or deleted to open the action configuration pane and configure the properties.

  9. In the Change type field, select Added.

  10. In the Table Name field, find/select the Tasks table.

  11. In the Scope field, select Organization.

    Screenshot of when a record is created with Environment set to the default, Table Name set to Tasks, and Scope set to Organization.

    Note

    If the trigger shows Invalid connection, select Change connection from the action configuration pane on the left. You are either prompted to sign in or select your existing connection.

    Screenshot of changing the connection in the action configuration panel.

    Next we add a planner task.

  12. In the Copilot pane on the right, type in When a new row is added to a Dataverse table, add a new planner task and press ENTER.

    Screenshot of how to change the connection in the action configuration pane.

  13. Copilot expands the flow and adds the action Create a task.

    Note

    It's possible Copilot deleted the Table name from the trigger. Verify the Tasks table is still selected, then continue.

  14. Select the Create a task action to open the properties in the action configuration pane on the left.

    Screenshot of Planner Task parameter options for Create a Task action.

  15. For Group ID, select the dropdown and select the Group that has your Planner plan. In our example, I select Sales and Marketing.

  16. For Plan ID, select the plan from the dropdown. In our example, we're selecting Product Launch Event.

  17. In the Title field, enter some text and then add the Subject from the dynamic content pane. In our example, for the Title field, we enter Begin onboarding process for:

  18. Select the lighting bolt to bring up the dynamic content options. Since we're looking for the subject, I start typing Subject. Once the subject pops up in the dynamic content box, select it.

    Screenshot of the planner task dynamic content subject.

  19. Select Advanced parameters then select Bucket Id. You can select out of the advanced parameters popup to close it. The Bucket ID field now shows below the Advanced parameters.

  20. For Bucket ID, select the bucket to create the task in from the dropdown (optional). In our example, we can select To do.

    Screenshot of Create a planner task with Group ID, Plan ID, Title, and Bucket ID.

    See create a task parameters for information about the other fields you can add to your task.

  21. Select Save from the upper right menu to save the flow.

Now, when new tasks are added to the Tasks table, a new task is created in the "Product Launch Event" in Planner.

Limitations of trigger-based logic

Triggers like When an item is created, When a item is updated, and When an item is deleted start your flow within a few minutes after the event occurs. In rare cases, it might take up to two hours for your flow to be triggered.

When the trigger occurs, the flow receives a notification, but the flow runs on the data that exists when the action runs. For example, if new item creation triggers your flow, and you update the item twice before the flow runs, your flow runs only once with the latest data.

Specify advanced options

When you add a step to a flow, you can select Advanced parameters (or Show advanced options in the old designer) to add a filter or order-by query that controls how the data is filtered.

For example, you can use a filter query to retrieve only active Accounts ordered by email address when retrieving a list of rows. In the example below we have Filter Rows and Sort By selected from Advanced parameters. To retrieve only active accounts, we're using status eq 0. To order the list by email address, we use the Email column name. For more about filter and order by queries, see MSDN: $filter and MSDN: $orderby.

Screenshot of List rows with the table Name set to Accounts using Filter Rows and Sort By.

Best practices for advanced options

When you add a value to a column, you must match the column type. You must match it regardless of whether you enter a value or select a value in the dynamic content pane.

Column type How to use Where to find Name Data type
Text columns Text columns require a single line of text or dynamic content that's a text-type column. Examples include the Category and Sub-Category columns. Solutions > Default Solution > Task > Columns Category Text
Integer columns Some columns require an integer or dynamic content that's an integer-type column. Examples include the Percent Complete and Duration columns. Solutions > Default Solution > Task > Columns Percent complete Whole Number
Date columns Some columns require a date entered in mm/dd/yyyy format or dynamic content that's a date-type column. Examples include the Created On, Start Date, Actual Start, Last on Hold Time, Actual End, and Due Date columns. Solutions > Default Solution > Task > Columns Created on Date and Time
Columns that require both a record ID and a lookup type Some columns that reference another table record require both the record ID and the lookup type. Solutions > Default Solution > Account > Columns Accountid Primary Key