Exercise - Create a cloud flow with a Dataverse connector

Completed

In this exercise, you use the Dataverse connector to create a cloud flow that monitors the status of projects that are related to Contoso's Innovation Challenge. Your flow triggers if the budget status or the schedule performance changes. Additionally, the flow completes a series of evaluations and then acts on the results.

After you define the trigger to only act when either named column is modified, you'll build the conditions of the actions that are taken:

  • If this project is on track, complete this action (change the status field).

  • If the project isn't on track, continue a further evaluation to determine the next action.

In addition to updating the Status field, you set up the system to add a task as needed. Then, you create a dynamic HTML table to include in your email notification.

Prerequisite - Environment with sample apps

You'll need to use an environment in which the sample apps have been installed. This happens when creating an environment. You can follow these steps from the Power Platform admin center (if you already have the sample apps, you can skip to the "Requirements").

  1. Select Environments > New.

  2. In the New environment panel that appears on the right of your screen, input (at a minimum) a Name then toggle Add a Dataverse data store? to Yes. Select Next.

  3. In the Add Dataverse panel that appears, select a Security group by clicking on the + Select button and select one of the groups (it can be Open access / none, but you must select one). Select Done in the Edit security group panel to continue.

  4. Select Save in the Add Dataverse panel to complete the process.

Power Apps does the rest, creating a new environment with Dataverse and the sample Model-driven apps.

Requirements

Your project needs to meet the following requirements:

  • The flow should trigger only if the budget status and/or the schedule performance columns have value. The flow shouldn't trigger if both columns are empty.

    • If the budget status is on budget or under budget, and if schedule performance is on time or ahead, set the project status to green.

    • If the budget status is over budget, or if schedule performance is behind, set the project status to red and then create a task and associate it with the project that triggered the flow.

    • Otherwise, set the project status to yellow and then create a task and associate it with the project that triggered the flow.

  • Find the project lead of the project that triggered the flow, and then obtain all projects that they own. Send an email that lists all projects that they lead, including the project name and the status of the project (green, yellow, red). For this exercise, you might use your user's email instead.

Prepare the environment

Your first task is to prepare the environment by following these steps:

  1. Go to Power Apps maker portal.

  2. Select the correct environment and then select Apps.

  3. Select the Innovation Challenge application and then select Play.

  4. The Innovation Challenge application should launch. Select Team Projects and then open the Fleet Automation project.

    The columns that you want are located in the Status section of the form.

    • Project Status is the column that the flow should update.

    • Budget status and Schedule performance should trigger the flow.

    Screenshot showing the Status section of the form.

  5. Locate the Project lead column. This application uses the Owner user as the project lead. The flow sends the email to this user. You might use the email of your user. For this sample application, the signed-in user, the owner, and the project lead are the same.

    Screenshot showing the Project lead column.

  6. Close the application browser window or tab.

  7. Return to the Power Apps maker portal, select Solutions, and then open Default Solution.

    Screenshot showing the default solution.

  8. Search for team project, expand the Team Project table, and then select Columns.

  9. Locate and open the Budget status column.

    Screenshot showing the Budget status column.

  10. Locate the choices, which are the choice values that the flow checks. Note these values and their corresponding labels because it's how you would locate option-set values.

  11. Expand Advanced options and locate the Logical name column, where you can find the columns' logical names. In this case, the name is "sample_budgetstatus."

    Screenshot showing the Budget status column options.

  12. Close the Column editor panel (or select the Cancel button).

  13. Locate and open the Schedule performance column.

  14. Locate the Choices, expand the Advanced options and note the logical name for the Schedule performance column.

  15. The details for both columns are as follows. Don't add commas.

    • Budget status logical name sample_budgetstatus

      • Over budget - 727000000

      • On budget - 727000001

      • Under budget - 727000002

    • Schedule performance logical name sample_scheduleperformance

      • On time - 727000000

      • Ahead - 727000001

      • Behind - 727000002

  16. Note the logical name and values and continue to the next part of the exercise.

Create the flow

Follow these steps to create the flow:

  1. Go to the Power Automate portal.

  2. Select the correct environment and then select My flows.

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

    Screenshot showing the create new automated cloud flow button.

  4. Enter Project status monitor for the Flow name. Search for and select When a new row is added, modified or deleted Microsoft Dataverse, and then select Create.

    Screenshot showing the Build an automated cloud flow dialog.

  5. If your connection has an error, follow the prompts to resolve. Select the trigger and then change the name to When a project budget status or schedule changes.

  6. Select Modified for the Change Type, select Team Projects for the Table Name, select Organization for Scope, and then select Show all next to Advanced parameters.

    Screenshot showing the trigger configuration.

  7. You only need to get the Budget status and Schedule performance columns. In the Select Columns field, paste the following budget status and schedule performance logical names, separated by a comma:

    sample_budgetstatus,sample_scheduleperformance

  8. You don't want the flow to be triggered if the Budget status and Schedule performance columns are empty. Therefore, in the Filter Rows field, paste the following test. Notice that you're using the columns' logical names again.

    sample_budgetstatus ne null or sample_scheduleperformance ne null

  9. The trigger should now resemble the following image. Select + Insert a new step and then select Add an action.

    Screenshot showing the Add an action button.

  10. Search for initialize and then select Initialize variable.

  11. Rename the action to Initialize on track, enter OnTrack for the Name, select Boolean for the Type, and then select true for the initial Value.

    Screenshot showing the variable.

  12. Select + Insert a new step under the Initialize on track step and then select Add an action.

  13. Search for control and then select Condition.

  14. Select the condition that you added and then rename it to Check project status.

  15. Put your cursor in the Choose a value field and then select the Insert Dynamic Content option (the "lightning bolt"), or you can type a "/" to bring up the option selection.

    Screenshot showing the Insert Dynamic Content option.

  16. Search for and select Budget status from the Dynamic content panel.

    Screenshot showing the Budget status selection.

  17. Enter 727000001 in the second Choose a value field on the right side of the comparison. This entry is the On budget option-set value for this column.

  18. Select the + New item in the Check project status dropdown menu and then select + Add Row.

    Screenshot showing the Add row option.

  19. Enter a slash (/) in the Choose a value field and then select Insert Dynamic Content.

  20. Search for and select Budget status from the Dynamic content pane.

  21. Enter 727000002 in the second Choose a value field. This entry is the Under budget option-set value for this column.

  22. Select both checkboxes, select the ...More commands menu, and then select Make Group.

    Screenshot showing the Make Group option.

  23. Change the group condition to OR.

  24. Select the + New item option outside the group and then select + Add Row.

    Screenshot showing the add new item option after the group.

  25. Select or enter a slash (/) within the Choose a value field on the left and then select Insert Dynamic Content.

  26. Search for and select Schedule performance from the Dynamic content pane.

  27. Enter 727000000 in the second Choose a value field. This entry is the On time option-set value for this column.

  28. Select + New item and then select + Add Row.

  29. Enter a slash (/) in the left Choose a value field and then select Insert Dynamic Content.

  30. Search for and select Schedule performance from the Dynamic content pane.

  31. Enter 727000001 in the second Choose a value field. This entry is the Ahead option-set value for this column.

  32. Select the checkboxes of the two conditions that you added, select the ...More commands menu, and then select Make Group.

  33. Change the group condition to OR.

The completed condition should now resemble the following image.

Screenshot showing the complete condition.

Update the project status to green

Your next task is to update the project status to Green by following these steps:

  1. Select the Insert a new step button of the True branch and then select Add an action.

    Screenshot of the Add an action button below the True branch.

  2. Search for and select Update a row from the Microsoft Dataverse connector.

  3. Select the Update a row action that you added.

  4. Rename the step to Update for green, select Team Projects for the Table Name, enter a slash (/) in the Row ID field, and then select Insert Dynamic Content.

    Screenshot showing the Insert Dynamic Content option below the Row I D field.

  5. Select Team Project from the Dynamic content pane.

    Screenshot showing Team Project selected from the Dynamic content pane.

  6. Select Show all.

  7. Scroll down and select Green from the Project Status dropdown menu.

    Screenshot showing the green project status.

  8. Select the Save button and then wait for the flow to save.

Don't navigate away from this page.

Check for over budget and behind

Follow these steps to check for over budget and behind:

  1. Select the Insert a new step button of the False branch and then select Add an action.

  2. Search for control and then select Condition.

  3. Select the condition that you added.

  4. Rename the condition to Check if over budget and behind.

  5. Enter a slash (/) in the left Choose a value field and then select Insert Dynamic Content.

    Screenshot showing the red condition dynamic content.

  6. Select Budget status from the Dynamic content pane and then enter 727000000 in the right side Choose a value field.

  7. Select the + New item dropdown menu and then select + Add Row.

  8. Enter a slash (/) in the left Choose a value field and then select Insert Dynamic Content.

  9. Select Schedule performance from the Dynamic content pane and then enter 727000002 in the right side Choose a value field.

Update the project status to red

The next task is to update the project status to Red by following these steps:

  1. The condition should now resemble the following image. Select the Insert a new step button from the True branch of the Check if over budget and behind condition and then select Add an action.

    Screenshot showing the Check if over budget and behind condition.

  2. Search for and select Update a row from the Microsoft Dataverse connector.

  3. Select the Update a row action that you added.

  4. Rename the step to Update for red, select Team Projects for the Table Name, enter a slash (/) in the Row ID field, and then select Insert Dynamic Content.

  5. Select Team Project from the Dynamic content pane.

  6. Select Show all.

  7. Scroll down and select Red from the Project Status dropdown menu.

    Screenshot showing Red selected as the project status.

Update the project status to yellow

To update the project status to Yellow, follow these steps:

  1. Select the Insert a new step button from the False branch of the Check if over budget and behind condition and then select Add an action.

  2. Search for and select Update a row from the Microsoft Dataverse connector.

  3. Select the Update a row action that you added.

  4. Rename the step to Update for yellow, select Team Projects for the Table Name, enter a slash (/) in the Row ID field, and then select Insert Dynamic Content.

  5. Select Team Project from the Dynamic content pane.

  6. Select Show all.

  7. Scroll down and select Yellow from the Project Status dropdown menu.

    Screenshot showing yellow selected for the project status.

  8. Select Save and then wait for the flow to save.

Don't navigate away from this page.

Update and check the variable

Now, you can update and check the variable by following these steps:

  1. Select the Insert a new step button from beneath the Check if over budget and behind condition and then select Add an action.

    Screenshot showing the Add an action button located after the condition.

  2. Search for and select Set variable.

  3. Rename the step to Set on track, select OnTrack for the Name, and then select false for Value.

    Screenshot showing the set variable step.

  4. Select the Insert a new step button located outside the Check project status condition and then select Add an action.

    Screenshot showing the Add an action button after the condition.

  5. Search for control and then select Condition.

  6. Rename the condition to Check if on track.

  7. Enter a slash (/) in the left Choose a value field and then select Insert Dynamic Content.

  8. Select the OnTrack variable from the Dynamic content pane.

  9. Enter a slash (/) in the right side Choose a value field and then select Insert Expression.

  10. Enter false for the expression and then select Add.

    Screenshot showing the expression.

Create a task

To create a task, follow these steps:

  1. Select the Insert a new step button from the True branch of the Check if on track condition and then select Add an action.

  2. Search for and select Add a new row from the Microsoft Dataverse connector.

  3. Rename the step to Create task, select Tasks for the Table Name, and then enter Project Status Review for the Subject.

    Screenshot showing the task subject.

  4. Scroll down to locate the Regarding (Team Projects) field.

  5. Enter sample_teamprojects() in the Regarding (Team Projects) field.

  6. Enter a slash (/) inside the parentheses and then select Insert Dynamic Content.

    Screenshot showing the Insert Dynamic Content project option.

  7. Select Team Project from the When a project budget status or schedule changes trigger.

    Screenshot showing Team Project selected from the trigger.

  8. Select Save and then wait for the flow to save.

Don't navigate away from this page.

Get the team project list and send the report

In this next task, you get the team project list for the user and then send a status report.

  1. Select the Insert a new step button from beneath the Check if on track condition and then select Add an action.

  2. Search for and select List rows from the Microsoft Dataverse connector.

  3. Rename the step to List user projects, select Team Projects for the Table Name, and then select Show all.

    Screenshot showing the Show all button of the List rows step.

  4. Enter sample_name, sample_projectstatus in the Select Columns field.

  5. Enter _owninguser_value eq in the Filter Rows field.

  6. Enter a space after eq and then select Insert Dynamic Content.

  7. Select Owner (Value) from the Dynamic content pane from the trigger step.

    Screenshot showing the Filter Rows value.

  8. Select the Insert a new step button located beneath the List user projects step and then select Add an action.

  9. Search for HTML table and then select Create HTML table.

  10. Rename the step to Create projects table.

  11. Enter a slash (/) in the From field and then select Insert Dynamic Content.

  12. Select body/value (List of items) from the Dynamic content pane and then select Show all.

    Screenshot showing the Show all button of the Create projects table step.

  13. Select Custom for Columns.

  14. Enter Name under the header and then select the value side to Insert Dynamic Content.

  15. Select Name from the List user projects step.

    Screenshot showing the project name.

  16. Enter Status in the second row under the header, enter a slash (/) in the Value field of the second row, and then select Insert Expression.

  17. Paste the following expression and then select Add.

    item()?['sample_projectstatus@OData.Community.Display.V1.FormattedValue']

    Screenshot showing the status expression.

  18. Select the Insert a new step button located beneath the Create projects step and then select Add an action.

  19. Search for send email and then select Send an email (V2) for Microsoft Office 365 Outlook.

  20. Sign in if prompted.

  21. Rename the step to Send report.

  22. Provide your user's email for the To field.

  23. Enter Status Report for Subject.

  24. Enter Status of your projects and then make it bold format.

  25. Below this line (still in the Body) enter a slash (/), and then select Insert Dynamic Content. Add the HTML output table.

    Screenshot showing the Send report step.

  26. Select Save and then wait for the flow to save.

Test the flow

Your last task in this exercise is to test your flow by following these steps:

  1. Go to Power Apps maker portal.

  2. Make sure that you're in the correct environment and then select Apps.

  3. Select the Innovation Challenge application and then select Play.

  4. Select Team Projects and then open the Fleet Automation project.

  5. Select Over budget for Budget status, select Behind for Schedule performance, and then select Save.

    Screenshot showing the project form.

  6. Refresh the form. The Project Status should change to Red and a Project Status Review task should display.

    Screenshot showing the updated project status and the created task.

  7. Go to Outlook. You should receive a Status Report email.

    Screenshot showing the status report email.

  8. You can test the flow for Red and Yellow status.