Practice Lab 6.1 – Cloud flows

Scenario

You are a Power Platform functional consultant and have been assigned to the Fabrikam project for the next stage of the project.

In this practice lab, you change an existing approvals flow and add error handling. You will also set the value of the environment variable used by the flow. You will also create a new flow to automatically set the actual end date on projects. You will call a Power Automate cloud flow from a canvas app.

Exercise 1 – Edit approval cloud flow

In this exercise, you will enhance the existing approvals flow.

Task 1.1 – Change the approver in flow

In this task, you will perform the following changes to the flow:

  • Replace the Get Approver row with the calculated column for Approver Email Address
  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, select Cloud flows.

  6. Select the Request Approval flow, select the ellipsis , and select Edit > Edit in new tab.

  7. If a Welcome to Power Automate dialog appears, select Get started.

  8. Select the Start and wait for an approval step.

    Note: The Item link field use an environment variable, Outcome form link.

  9. Clear the current contents of the Assigned To field.

  10. In Dynamic content, search for email and select Approver Email. You may need to scroll down in the Dynamic Content window to see this.

  11. On the Get Approver step, select the ellipsis (…) and select Delete.

    Approval step.

  12. Select Save.

Task 1.2– Check if an approver is assigned to the outcome

In this task, you will perform the following changes to the flow:

  • Add check for missing approver
  1. Hover the mouse between the Get Outcome and Start and wait for an approval steps and select the + (Insert new step) > Add an action.

  2. Select the Control connector and then select Condition.

  3. Select the first Choose a value field.

  4. In Dynamic content, search for approver and select Approver Email.

  5. Change the Operator to is not equal to.

  6. Select the right-hand Choose a value field.

  7. In Dynamic content, select the Expression tab.

  8. Enter null and select OK.

  9. In the condition step, select + Add and then select Add row.

  10. Select the Choose a value field.

  11. In Dynamic content, select the Expression tab.

  12. Enter length() and position the cursor between the brackets.

  13. Select the Dynamic content tab, select See more for Get Outcome, and choose Approver Email and select OK.

  14. The expression should be as follows:

    length(outputs('Get_Outcome')?['body/contoso_approveremail'])

  15. Change the Operator to is greater than.

  16. Select the right-hand Choose a value field and enter 0

  17. In the condition step, note the And drop-down is set to And.

    Condition.

  18. Drag the Start and wait for an approval step into the If yes branch of the condition.

  19. Drag the Check Approval response step into the If yes branch of the condition.

  20. In the If no branch of the condition, select Add an action.

  21. Select the Control connector and then select Terminate.

  22. Select Failed for the Status drop down.

  23. Enter NO_APPROVER for Code.

  24. Enter No approver for outcome and in Dynamic content select Outcome Title.

    Flow after changes in this task.

  25. Select Save.

Task 1.3 – Error handling

In this task, you will perform the following changes to the flow:

  • Add error handing to the approval step
  1. On the Check Approval Response step, select the ellipsis (…) and select Configure run after. Only is successful is selected.

  2. Select Cancel.

  3. Hover the mouse between the Start and wait for an approval and Check Approval Response steps and select the + (Insert new step) and then select Add a parallel branch.

  4. Select the Control connector and then select Terminate.

  5. Select Failed for the Status drop down.

  6. Enter APPROVAL_EXPIRED for Code.

  7. Enter Approval timed out for and in Dynamic content, select Outcome Title.

  8. On the Terminate 2 step, select the ellipsis (…) and select Configure run after.

  9. Uncheck is successful.

  10. Check the other three boxes.

  11. Select Done.

    Error handing and parallel branch.

  12. Select Save

Task 1.4 – Set status to rejected

In this task, you will perform the following changes to the flow:

  • Set status to rejected if the approval is rejected
  1. Select and expand the Check Approval Response step.

  2. In the If no branch of the condition, select Add an action.

  3. Select the Microsoft Dataverse connector and then select Update a row.

  4. On the Update a row step, select the ellipsis (…) and select Rename.

  5. Enter Set Outcome to rejected

  6. Select Outcomes for Table name.

  7. Select the Row ID field.

  8. In Dynamic content, search for outcome and select Outcome under the Get Outcome section.

  9. Expand Show advanced options.

  10. Select No for Approved.

  11. Select Rejected for Status Reason.

  12. Select Save

  13. Select the back arrow icon in the top-left of the flow editor.

    Note: If you receive an error message stating This isn’t the latest content, select Overwrite other people’s changes then select Apply to move forward.

Exercise 2 – Edit environment variable

In this exercise, you will find the URL for your environment and update the environment variable.

Task 2.1 – Find the URL for your environment

In this task, you will:

  • Discover the URL for the outcome form in the model-driven app
  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, select Apps.

  6. Select the Environmental Project Delivery app, select the ellipsis (…), and select Play.

  7. In the left-hand navigation, select Outcomes.

  8. Open any outcome record.

  9. Copy the URL of the window.

  10. Open Notepad and paste the URL.

  11. The URL will look like the link below.

    https://practice.crm.dynamics.com/main.aspx?appid=de79a38a-138b-4a89-91fb-b12ca31d227b&pagetype=entityrecord&etn=contoso_outcome&id=717c05a8-2c2c-ed11-9db1-00224820046d

  12. Copy everything before the last GUID.

    https://practice.crm.dynamics.com/main.aspx?appid=de79a38a-138b-4a89-91fb-b12ca31d227b&pagetype=entityrecord&etn=contoso_outcome&id=

Task 2.2 – Update environment variable

In this task, you will:

  • Update the environment variable
  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, select Environment variables.

  6. Select the Outcome form link variable, select the ellipsis (…), and select Edit.

  7. Select + New value.

  8. Paste the URL from the previous task.

  9. Select Save.

Task 2.3 – Restart flow

In this task, you will:

  • turn the flow off and on again to pick up the change to the environment variable
  1. In the Objects pane on the left, select Cloud flows.

  2. Select the Request Approval flow, select the ellipsis (…), and select Turn off.

  3. Select the Request Approval flow, select the ellipsis (…), and select Turn on.

Exercise 3 - Create automatic cloud flow for project status

In this exercise, you will create a new cloud flow that is triggered when the project status is updated. The flow will set the actual end date if the project status is completed.

Task 3.1 - Create a new cloud flow

In this task, you will perform the following:

  • create a new flow that is triggered by project status change
  • add an action to set the actual end date
  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, select Cloud flows.

  6. Select + New > Automation > Cloud flow > Automated.

  7. Enter Set Project End Date for Flow name.

  8. Search for Dataverse in Chose how to trigger this flow and select the When a row is added, modified, or deleted action.

  9. Select Create.

  10. Select Modified for Change type.

  11. Select Projects for Table name.

  12. Select Organization for Scope.

  13. Select the ellipsis (…) and select Rename.

  14. Enter Project Status changed

  15. Expand Show advanced options.

  16. For the Select columns field, enter contoso_projectstatus

    The flow will only trigger when the project status value is changed.

  17. Select + New step.

  18. Select the Microsoft Dataverse connector and then select Update a row.

  19. On the Update a row step, select the ellipsis (…) and select Rename.

  20. Enter Set Actual End Date

  21. Select Projects for Table name.

  22. Select the Row ID field.

  23. In Dynamic content, search for project and select Project.

  24. Expand Show advanced options.

  25. Select the Actual End field.

  26. In Dynamic content, select the Expression tab.

  27. Enter utcNow() and select OK.

  28. Select Save.

Task 3.2 - Configure trigger

In this task, you will perform the following:

  • restrict the flow trigger to only fire when the project status is completed and the actual end date has not been entered
  1. Select the trigger step (Project Status changed).

  2. Expand Show advanced options if not already expanded.

  3. Select Filter rows and enter the following OData filter expression:

    (contoso_projectstatus eq 330650003 and contoso_actualenddate eq null)

  4. Select Save.

  5. Select the back arrow icon in the top-left of the flow editor.

Exercise 4 – Call Power Automate from a Canvas app

In this exercise, you will add a Power Automate flow to the canvas app to reset the status of a Milestone.

Task 4.1 - Create flow

In this task, you will perform the following changes to the screen:

  • create an instant flow for use in the canvas app
  • perform a flow action to reset the status of a Milestone
  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, select Cloud flows.

  6. In the solution, select + New > Automation > Cloud flow > Instant.

    NOTE: If a Welcome to Power Automate dialog appears, select Get started.

  7. Enter Reset milestone status for Flow name.

  8. Select PowerApps (V2) for Chose how to trigger this flow.

  9. Select Create.

  10. Select the Power Apps (V2) trigger step.

  11. Select + Add an input.

  12. Select Text.

  13. Enter ID for Input.

  14. Enter Milestone for Please enter your input.

  15. Select + New step.

  16. Select the Microsoft Dataverse connector.

  17. Select the Update a row action.

  18. Select Milestones for Table name.

  19. Select the Row ID field.

  20. In Dynamic content, select ID.

  21. Expand Show advanced options.

  22. Enter 0 for Milestone Percentage Complete.

  23. Select Planned for Milestone status.

  24. Select Save and wait for the flow to save.

  25. Select the 🡠 back arrow in the top left of the flow editor.

Task 4.2 - Add flow to canvas app

In this task, you will perform the following changes to the screen:

  • add the flow to the canvas app
  • run the flow from a button
  1. In the Objects pane on the left, select Apps.

  2. Select the Environmental Work Delivery app, select the Commands menu (…), and select Edit > Edit in new tab.

  3. In the left navigation, select Power Automate.

  4. Select + Add flow.

  5. Select Reset milestone status. The flow will be added to the app.

  6. In the Tree view, select and expand OutcomeScreen.

  7. Select SaveBtn.

  8. Select the ellipsis menu (…) next to the button in the Tree view and select Copy.

  9. In the Tree view, select and expand MilestoneScreen.

  10. Right-click in the app area and select Paste.

  11. Select the ellipsis (…) next to SaveBtn_1 and select Rename.

  12. Enter ResetBtn

  13. Select Text in the Property Selector and replace with "Reset"

  14. Select DisplayMode in the Property Selector and change the formula to use the MilestoneGallery

  15. Select the OnSelect property in the Property Selector.

  16. Enter the following formula:

    Resetmilestonestatus.Run(MilestoneGallery.Selected.Milestone);Refresh(Milestones);

  17. Drag ResetBtn under the form.

Task 4.3 - Publish and share the app

  1. Select Save.

  2. Select Publish.

  3. Select Publish this version.

  4. Select Share.

  5. Enter Alex in Enter a name, email address, or Everyone and select Alex Wilber.

  6. Select Share.

  7. Enter Patti in Enter a name, email address, or Everyone and select Patti Fernandez.

  8. Check the Co-owner box.

  9. Select Share.

  10. Close the tab.

Exercise 5 – Solutions

In this exercise, you will export the solution from the Development environment and import it into the Production environment.

Task 5.1 – Export managed solution

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com

  2. Make sure you are in the Dev One environment.

  3. Select Solutions.

  4. Select the Fabrikam Environmental solution but do not open it.

  5. Select Export Solution.

  6. Select Next.

  7. Change the version number to 1.1.11.15

  8. Select Managed for Export As.

  9. Select Export.

  10. The export will be prepared in the background. When the solution is ready, select the Download button.

Task 5.2 – Export unmanaged solution

  1. Select the Fabrikam Environmental solution.

  2. Select Export Solution.

  3. Select Next.

  4. Change the version number to 1.1.11.15

  5. Select Unmanaged for Export As.

  6. Select Export.

  7. The export will be prepared in the background, when the solution is ready click the Download button.

Task 5.3 – Import managed solution

  1. Switch environments by using the Environment Selector in the upper right corner of the Maker portal.

  2. Select the Production environment from the list.

  3. Select Solutions.

  4. Select Import solution.

  5. Select Browse, change to the Downloads folder and select FabrikamEnvironmental_1_1_11_15_managed.zip and select Open.

  6. Select Next.

  7. Select Import. The solution will import in the background.