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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Open the Fabrikam Environmental solution.
-
In the Objects pane on the left, select Cloud flows.
-
Select the Request Approval flow, select the ellipsis …, and select Edit > Edit in new tab.
-
If a Welcome to Power Automate dialog appears, select Get started.
-
Select the Start and wait for an approval step.
Note: The Item link field uses an environment variable, Outcome form link.
-
Clear the current contents of the Assigned To field.
-
In Dynamic content, search for
email
and select Approver Email. You may need to scroll down in the Dynamic Content window to see this. -
On the Get Approver step, select the ellipsis (…) and select Delete.
-
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
-
Hover the mouse between the Get Outcome and Start and wait for an approval steps and select the + (Insert a new step) > Add an action.
-
Select the Control connector and then select Condition.
-
Select the first Choose a value field.
-
In Dynamic content, search for approver and select Approver Email.
-
Change the Operator to is not equal to.
-
Select the right-hand Choose a value field.
-
In Dynamic content, select the Expression tab.
-
Enter
null
and select OK. -
In the condition step, select + Add and then select Add row.
-
Select the Choose a value field.
-
In Dynamic content, select the Expression tab.
-
Enter
length()
and position the cursor between the brackets. -
Select the Dynamic content tab, select See more for Get Outcome, and choose Approver Email and select OK.
-
The expression should be as follows:
length(outputs('Get_Outcome')?['body/contoso_approveremail'])
-
Change the Operator to is greater than.
-
Select the right-hand Choose a value field and enter
0
-
In the condition step, note the And drop-down is set to And.
-
Drag the Start and wait for an approval step into the If yes branch of the condition.
-
Drag the Check Approval response step into the If yes branch of the condition.
-
In the If no branch of the condition, select Add an action.
-
Select the Control connector and then select Terminate.
-
Select Failed for the Status drop down.
-
Enter
NO_APPROVER
for Code. -
Enter
No approver for outcome
and in Dynamic content select Outcome Title. -
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
-
On the Check Approval Response step, select the ellipsis (…) and select Configure run after. Only is successful is selected.
-
Select Cancel.
-
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.
-
Select the Control connector and then select Terminate.
-
Select Failed for the Status drop down.
-
Enter
APPROVAL_EXPIRED
for Code. -
Enter
Approval timed out for
and in Dynamic content, select Outcome Title. -
On the Terminate 2 step, select the ellipsis (…) and select Configure run after.
-
Uncheck is successful.
-
Check the other three boxes.
-
Select Done.
-
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
-
Select and expand the Check Approval Response step.
-
In the If no branch of the condition, select Add an action.
-
Select the Microsoft Dataverse connector and then select Update a row.
-
On the Update a row step, select the ellipsis (…) and select Rename.
-
Enter
Set Outcome to rejected
-
Select Outcomes for Table name.
-
Select the Row ID field.
-
In Dynamic content, search for
outcome
and select Outcome under the Get Outcome section. -
Expand Show advanced options.
-
Select No for Approved.
-
Select Rejected for Status Reason.
-
Select Save
-
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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Open the Fabrikam Environmental solution.
-
In the Objects pane on the left, select Apps.
-
Select the Environmental Project Delivery app, select the ellipsis (…), and select Play.
-
In the left-hand navigation, select Outcomes.
-
Open any outcome record.
-
Copy the URL of the window.
-
Open Notepad and paste the URL.
-
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
-
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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Open the Fabrikam Environmental solution.
-
In the Objects pane on the left, select Environment variables.
-
Select the Outcome form link variable, select the ellipsis (…), and select Edit.
-
Select + New value.
-
Paste the URL from the previous task.
-
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
-
In the Objects pane on the left, select Cloud flows.
-
Select the Request Approval flow, select the ellipsis (…), and select Turn off.
-
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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Open the Fabrikam Environmental solution.
-
In the Objects pane on the left, select Cloud flows.
-
Select + New > Automation > Cloud flow > Automated.
-
Enter
Set Project End Date
for Flow name. -
Search for
Dataverse
in Choose your flow’s trigger and select the When a row is added, modified, or deleted action. -
Select Create.
-
Select Modified for Change type.
-
Select Projects for Table name.
-
Select Organization for Scope.
-
Select the ellipsis (…) and select Rename.
-
Enter
Project Status changed
-
Expand Show advanced options.
-
For the Select columns field, enter
contoso_projectstatus
The flow will only trigger when the project status value is changed.
-
Select + New step.
-
Select the Microsoft Dataverse connector and then select Update a row.
-
On the Update a row step, select the ellipsis (…) and select Rename.
-
Enter
Set Actual End Date
-
Select Projects for Table name.
-
Select the Row ID field.
-
In Dynamic content, search for
project
and select Project. -
Expand Show advanced options.
-
Select the Actual End field.
-
In Dynamic content, select the Expression tab.
-
Enter
utcNow()
and select OK. -
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
-
Select the trigger step (Project Status changed).
-
Expand Show advanced options if not already expanded.
-
Select Filter rows and enter the following OData filter expression:
(contoso_projectstatus eq 330650003 and contoso_actualenddate eq null)
-
Select Save.
-
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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Open the Fabrikam Environmental solution.
-
In the Objects pane on the left, select Cloud flows.
-
In the solution, select + New > Automation > Cloud flow > Instant.
NOTE: If a Welcome to Power Automate dialog appears, select Get started.
-
Enter
Reset milestone status
for Flow name. -
Select When Power Apps calls a flow (V2) for Choose how to trigger this flow.
-
Select Create.
-
Select the Power Apps (V2) trigger step.
-
Select + Add an input.
-
Select Text.
-
Enter
ID
for Input. -
Enter
Milestone
for Please enter your input. -
Select + New step.
-
Select the Microsoft Dataverse connector.
-
Select the Update a row action.
-
Select Milestones for Table name.
-
Select the Row ID field.
-
In Dynamic content, select ID.
-
Expand Show advanced options.
-
Enter
0
for Milestone Percentage Complete. -
Select Planned for Milestone status.
-
Select Save and wait for the flow to save.
-
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
-
In the Objects pane on the left, select Apps.
-
Select the Environmental Work Delivery app, select the Commands menu (…), and select Edit > Edit in new tab.
-
In the left navigation, select Power Automate.
-
Select + Add flow.
-
Select Reset milestone status. The flow will be added to the app.
-
In the Tree view, select and expand OutcomeScreen.
-
Select SaveBtn.
-
Select the ellipsis menu (…) next to the button in the Tree view and select Copy.
-
In the Tree view, select and expand MilestoneScreen.
-
Right-click in the app area and select Paste.
-
Select the ellipsis (…) next to SaveBtn_1 and select Rename.
-
Enter
ResetBtn
-
Select Text in the Property Selector and replace with
"Reset"
-
Select DisplayMode in the Property Selector and change the formula to use the
MilestoneGallery
-
Select the OnSelect property in the Property Selector.
-
Enter the following formula:
Resetmilestonestatus.Run(MilestoneGallery.Selected.Milestone);Refresh(Milestones);
-
Drag ResetBtn under the form.
Task 4.3 - Publish and share the app
-
Select Save.
-
Select Publish.
-
Select Publish this version.
-
Select Share.
-
Enter
Alex
in Enter a name, email address, or Everyone and select Alex Wilber. -
Select Share.
-
Enter
Patti
in Enter a name, email address, or Everyone and select Patti Fernandez. -
Check the Co-owner box.
-
Select Share.
-
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
-
Navigate to the Power Apps Maker portal
https://make.powerapps.com
-
Make sure you are in the Dev One environment.
-
Select Solutions.
-
Select the Fabrikam Environmental solution but do not open it.
-
Select Export Solution.
-
Select Next.
-
Change the version number to
1.1.11.15
-
Select Managed for Export as.
-
Select Export.
-
The export will be prepared in the background. When the solution is ready, select the Download button.
Task 5.2 – Export unmanaged solution
-
Select the Fabrikam Environmental solution.
-
Select Export Solution.
-
Select Next.
-
Change the version number to
1.1.11.15
-
Select Unmanaged for Export as.
-
Select Export.
-
The export will be prepared in the background, when the solution is ready click the Download button.
Task 5.3 – Import managed solution
-
Switch environments by using the Environment Selector in the upper right corner of the Maker portal.
-
Select the Production environment from the list.
-
Select Solutions.
-
Select Import solution.
-
Select Browse, change to the Downloads folder and select FabrikamEnvironmental_1_1_11_15_managed.zip and select Open.
-
Select Next until Import
-
Select Import. The solution will import in the background.