Using Desktop Flows from Cloud Flows
Scenario
In this lab, you will build cloud flows which integrate with the desktop flows.
High-level lab objectives
-
Use child flows to create a more maintainable cloud flow
-
Use desktop flows from cloud flow
Exercise #1: Lookup Loan Child flow
Task #1: Create child flow
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Click + New and select Automation | Cloud flow | Instant.
- Enter CF Lookup Loan for Flow name, select Manually trigger a flow, and click Create.
-
Expand the trigger by clicking on Manually trigger a flow.
-
Select + Add an input.
-
Select Text.
-
Enter LoanNumber and click + New step.
- Search for list rows and select List rows Microsoft Dataverse.
- Select Loans for Table name and click Show advanced options.
- Enter rc_loannumber eq for Filter rows and select LoanNumber from the dynamic content pane.
[!alert] If you do not see the Dynamic Content & Expression pop-up, increase your browser width or zoom out slightly to reveal it (Keyboard shortcut: Ctrl + -).
-
Add single quotes (‘) before and after LoanNumber
-
Click + New step.
-
Select Condition.
-
Click to select the first operand field, go to the dynamic content pane, and select the expression tab.
-
Paste the expression below and click OK. This checks if any rows were returned.
empty(outputs(‘List_rows’)?[‘body/value’])
-
Select is equal to for condition.
-
Click to select the second operand field, go to the dynamic content pane, and select the expression tab.
-
Type true and click OK.
- Go to the If yes branch and click Add an action.
- Select Respond to a PowerApp or flow.
- Click + Add an output.
-
Select Yes/No.
-
Enter LoanFound for title and click to select the value field.
-
Go to the Dynamic content pane and select the Expression tab.
-
Type false and click OK.
-
Click + Add an output again.
-
Select Text.
-
Enter LoanID for title.
-
Click on the value field, add an empty space.
- Click on the … more actions button and select Rename.
-
Rename the step Not found response.
-
Go to the If no branch and click Add an action.
- Select Respond to a PowerApp or flow.
-
Click + Add an output.
-
Select Yes/No.
-
Enter LoanFound for title and click to select the value field.
-
Go to the dynamic content pane and select the Expression tab.
-
Type true and click OK.
-
Click + Add an output again.
-
Select Text.
-
Enter LoanID for title.
-
Click to select the value field, go to the dynamic content pane, and select the Expression tab.
-
Paste the expression below and click OK. This gets the ID from the first row.
outputs(‘List_rows’)?[‘body/value’][0][‘rc_loanid’]
-
Click on the … more actions button and select Rename.
-
Rename the step Found response.
-
Click Save to save the flow.
- Click Test.
-
Select Manually and click Test.
-
Enter MC3747 for LoanNumber and click Run flow.
-
Click Done.
-
Click to expand the response step.
-
Make sure the output body matches your expectation.
- You may close the flow
Exercise #2: Inspection Child flow
Task #1: Setup Machine connection
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Click + New and select More | Connection Reference.
- Enter Desktop Flows for Display name, select Desktop flows for Connector, click on the Connection dropdown and select + New connection.
- Select Connect with username and password for Connect and select your desktop. If you don’t see your desktop here, go to desktop flow machine settings and make sure you have the Dev environment selected.
- Provide your username, password, and click Create. If your username doesn’t work try admin as the username.
-
Close the connection browser tab or window.
-
Click on the Refresh connection button.
- Select the connection you created and click Create.
Task #2: Create child flow
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Click + New and select Automation | Cloud flow | Instant.
-
Enter CF Manage Inspection Process for Flow name, select Manually trigger a flow, and click Create.
-
Expand the trigger and click + Add an input.
-
Select Text.
-
Enter PropertyAddress and click + Add an input again.
-
Select Text.
-
Enter LoanDrawID and click + Add an input one more time.
-
Select Text.
-
Enter Work. You should now have three input parameters. Click + New step.
- Select Run a flow built with Power Automate for desktop.
-
Select Perform Site Inspection for Desktop flow and select Attended for Run Mode.
-
Click on the WorkToInspect field and select Work from the dynamic content pane.
-
Click on the PropertyAddress and select PropertyAddress from the dynamic content pane.
-
Enter your name for Inspection account number.
-
Click + New step.
-
Search the connectors and actions for Parse JSON. Select the Parse JSON action which is part of the Data Operation connector.
- Click on the Content field and select SitePhotos from dynamic content pane.
-
Paste the JSON schema below in the Schema field and click + New step. Typically, you would generate this from a sample of the data expected.
{ "type":"object", "properties":{ "images":{ "type":"array", "items":{ "type":"object", "properties":{ "name":{ "type":"string" }, "url":{ "type":"string" } }, "required":[ "name", "url" ] } } } }
- Select the HTTP action.
- Select GET for Method, click on the URI field, and select url from the dynamic content pane.
-
Apply to each will be added automatically for you. Rename the Apply to each step Apply to each image.
-
Click Add an action.
- Select the Add a new row action from the Microsoft Dataverse connector.
- Select Inspection Photos for Table name, click on the Name field, and select name from the dynamic content pane.
- Rename the “Add a new row” step to Add inspection photo and click Show advanced options.
- Enter rc_loandraws() for Loan Draw, place your cursor inside the parentheses, and select LoanDrawID from the dynamic content pane.
-
Click on the Photo field, go to the dynamic content pane, and select the Expression tab.
-
Paste the expression below and click OK.
base64(body('HTTP'))
- Click + New step.
- Select the Update a row action from the Microsoft Dataverse connector.
-
Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.
-
Click Show advanced options.
- Click on the Inspected On field, go to the dynamic content pane, select the Expression tab, type utcNow() and click OK.
- Click on the Inspection Job field and select JobNumber from the dynamic content pane.
- Select Inspection Completed for Status Reason and click Hide advanced options.
-
Rename the step Update loan draw and click + New step.
-
Select the Respond to PowerApp or flow action from the PowerApps connector.
-
Click + Add an output.
-
Select Text.
-
Enter InspectionStatus, click on the value field and select InspectionStatus from the dynamic content pane.
-
Click + Add an output again.
-
Select Text.
-
Enter JobNumber, click on the value field and select JobNumber from the dynamic content pane.
-
Click Save to save the flow.
-
Click on the back arrow.
- Open the flow details.
-
Click Run.
-
If prompted, select Manually and click Test again.
-
Click Continue.
-
DO NOT navigate away from this page.
-
Start a new browser instance and navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Apps and launch the Loan Manager application.
-
Open the first loan record.
-
Click Related and select Loan Draws.
- Click + New Loan Draw.
-
Enter Test Draw for Name and click Save.
-
Go to the URL and copy the id GUID. Paste this id into Notepad, you will need it in future steps.
- Go back to the Cloud Flow and enter 123 Main Street for PropertyAddress, paste the id you copied in the LoanDrawID field, type Test work item for Work, and click Run flow.
-
Wait for the flow run to complete.
-
Close the run flow pane.
-
Go to the 28-day run history and click refresh until the flow run shows as Succeeded.
- Go back to the Loan Manager application, click Related and select Inspection Photos.
- You should see the inspection photos created by the flow.
Exercise #3: Funding Child flow
Task #1: Create child flow
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Click + New and select Automation | Cloud flow | Instant.
-
Enter CF Manage Woodgrove Funding Process for Flow name, select Manually trigger a flow, and click Create.
- Expand the trigger and click + Add an input.
-
Select Text.
-
Enter LoanNumber and click + Add an input again.
-
Select Text.
-
Enter LoanDrawID and click + Add an input again.
-
Select Text.
-
Enter RequestedAmount and click + Add an input again.
-
Select Text.
-
Enter InspectionJobID and click + Add an input again.
-
Select Number.
-
Enter RiskScore.
-
You should now have five inputs. Click + New step.
- Select the Run a flow built with Power Automate for desktop action.
-
Select Woodgrove Funding Manager Draw for Desktop flow and select Attended for Run Mode.
-
Click on the LoanNumber field and select LoanNumber from the dynamic content pane.
-
Click on the RequestedAmount field and select RequestedAmount from the dynamic content pane.
-
Click on the InspectionJobNumber field and select InspectionJobID from the dynamic content pane.
-
Type Yes for BorrowerApproved.
-
Click on the RiskScore field and select RiskScore from the dynamic content pane.
-
Enter your name for Username, pass@word1 for Password.
-
The run desktop flow should now look like the image below. Click + New step.
-
Select the Condition action from the Control connector.
-
Click on the first operand and select FundingStatus from the dynamic content pane.
-
Select is equal to for operator and enter Approved for the second operand.
-
Go to the If yes branch and click Add an action.
- Select the Update a row action from the Microsoft Dataverse connector.
- Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.
-
Click Show advanced options.
-
Click on the Amount Funded field and go to the dynamic content pane and select the Expression tab.
-
Paste the expression below and click OK.
replace(outputs('Run_a_flow_built_with_Power_Automate_for_desktop')?['body/FundedAmount'], '$','')
-
Click on the Funded On field, go to the dynamic content pane, and select the Expression tab.
-
Type utcNow() and click OK.
-
Click on the Funding Sequence Number field and select FundSequenceNumber from the dynamic content pane.
-
Click on the Funding Transfer Number field and select FundTransferNumber form the dynamic content pane.
-
Click on the RiskScore field and select RiskScore form the dynamic content pane.
-
Select Funding Approved for Status Reason and click Hide advanced options.
-
Rename the step Update for approved.
-
Go to the If no branch and click Add an action.
- Select the Update a row action from the Microsoft Dataverse connector.
- Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.
-
Click Show advanced options.
-
Select Funding Denied for Status Reason and click + New step.
- Select the Respond to PowerApps or flow action from the PowerApps connector.
-
Click + Add an output.
-
Select Text.
-
Enter FundingStatus, click on the value field and select FundingStatus from the dynamic content pane.
-
Click Save and wait for the flow to be saved.
-
Click Test.
-
Select Manually and click Test again.
-
Click Continue.
-
Enter JG7165 for LoanNumber, paste the id you copied in the previous exercise for LoanDrawID, enter 80000 for RequestedAmount, enter 123 for InspectionJobID, enter 50 for RiskScrore, and click Run flow.
- Wait for the flow run to complete, the flow run should succeed. Click Done to review the flow run history.
Exercise #4: Build Overall Process Flow
Task #1: Create a shared mailbox
- Navigate to https://admin.microsoft.com/ and click Show all.
- Go to the Admin centers area and select Exchange.
-
In the left side menu under Recipients select Mailboxes.
-
Click + Add a shared mailbox.
- Enter Funding for Display name, Funding for Email address, select your domain, and click Create.
- Click Add users to this mailbox.
-
Click + Add members.
-
Select your user and click Save. You may add other users to the shared mailbox.
-
Click Confirm.
-
Close the shared mailbox pane.
Task #2: Create flow
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Locate and open the CF Manage Inspection Process child flow.
- Go to the Run only users section and click Edit.
-
Select the desktop connection you created and click OK on the popup.
-
Click Save.
-
Click on the browser back button.
-
Locate and open the CF Manage Woodgrove Funding Process child flow.
-
Go to the Run only users section and click Edit.
-
Select the desktop connection you created and click OK on the popup.
-
Click Save.
-
Click on the browser back button.
-
Click + New and select Automation | Cloud flow | Automated.
- Enter Process Construction Funding Request for Flow name, select the When a new email arrives in a shared mailbox trigger, and click Create.
-
Select the Funding shared email you created for Original Mailbox Address, select Inbox for Folder, and click Show advanced options.
-
Select Yes for Include attachments and click on the … button of the trigger.
-
Select Rename.
-
Rename the trigger to When a new funding request email arrives.
-
Click + New step.
-
Select the Run a Child Flow action from the Flows connector.
-
Select CF Lookup Loan for Child flow.
-
Click on the LoanNumber field, go to the dynamic content pane, and select Subject.
-
Rename the step Lookup loan number.
-
Click + New step.
-
Select the Condition action from the Control connector.
-
Click to select the first operand field, go to the dynamic content pane, and select LoanFound.
-
Select is equal to for the operator and type True for the second operand field.
-
Rename the condition Check if loan number found.
-
Go to the If no branch and click Add an action.
-
Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.
- Click on the Original mailbox Address, click Add dynamic content and select To from the dynamic content pane.
-
Click on the To field, click Add dynamics content and select From from the dynamic content pane.
-
Type Loan number not found for Subject.
-
Type Loan # Body and select Subject from the dynamic content pane.
-
Add not found, contact your bank. to the body.
-
Rename the reply Send loan not found email and click Add an action.
- Select the Terminate action from the Control connector.
-
Select Succeeded for Status.
-
Click + New step.
- Select the Add a new row action from the Microsoft Dataverse connector.
-
Select Loan Draws for Table name.
-
Enter Loan draw for Name and click Show advanced options.
-
Enter 80000 for Amount Requested.
-
Type rc_loans() for Loan (Loans), place your cursor inside the parentheses, and select LoanID from the dynamic content pane.
-
Rename the step Create new loan draw row.
-
Click + New step.
-
Select the Run a Child Flow action from the Flows connector.
-
Select CF Manage Inspection Process for Child flow.
-
Enter 123 Main Street for PropertyAddress.
-
Click on the LoanDrawID field and select Loan Draw from the dynamic content pane.
-
Enter Test work item for Work.
-
Rename the child flow Run inspection process and click + New step.
-
Select the Run a Child Flow action from the Flows connector.
-
Select CF Manage Woodgrove Funding Process for Child flow.
-
Click on the LoanNumber field and select Subject from the dynamic content pane.
-
Click on the LoanDrawID field and select Loan Draw from the dynamic content pane.
-
Enter 80000 for RequestedAmount.
-
Click on the InspectionJobID field and select JobNumber from the dynamic content pane.
-
Enter 55 for RiskScore.
-
Rename the child flow Run funding process. Click Save.
-
Click + New step.
-
Select the Condition action from the Control connector.
-
Click on the first operand and select FundingStatus from the dynamic content pane.
-
Select is equals to for operator and enter Approved for the second operand.
-
Rename the condition Check approval status.
-
Go to the If yes branch and click Add an action.
-
Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.
-
Click on the Original Mailbox Address field, click Add dynamic content and select To from the dynamic content pane.
-
Click on the To field, click Add dynamics content and select From from the dynamic content pane.
-
Enter Draw Approved for Subject.
-
Type Your draw for in the Body and select Amount Funded from the dynamic content pane.
-
Add was approved to the body.
-
Rename the step Send approved draw email.
-
Go to the If no branch and click Add an action.
-
Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.
-
Click on the Original Mailbox Address field, click Add dynamic content and select To from the dynamic content pane.
-
Click on the To field, click Add dynamic content and select From from the dynamic content pane.
-
Enter Draw was not approved for Subject.
-
Type Your draw for in the Body and select Amount Funded from the dynamic content pane.
-
Add was not approved, please contact bank. to the body.
-
Rename the step Send draw not approved email.
-
Click Save and wait for the flow to be saved.
Task #3: Test flow
-
Click Test.
-
Select Manually and click Test again.
-
Send an email with the subject MC3747 from your email to the Funding shared email you created (Funding@yourdomain.onmicrosoft.com).
-
Wait for the flow to get triggered. Do not interact your computer while the flow is running.
-
The flow should run successfully.
- You should receive an email with the subject Draw Approved.