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

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Click + New and select Automation | Cloud flow | Instant.

Select new instant flow

  1. Enter CF Lookup Loan for Flow name, select Manually trigger a flow, and click Create.

Name the flow and select manual trigger

  1. Expand the trigger by clicking on Manually trigger a flow.

  2. Select + Add an input.

select add an input

  1. Select Text.

  2. Enter LoanNumber and click + New step.

add LoanNumber and select new step

  1. Search for list rows and select List rows Microsoft Dataverse.

search for and select List rows for Microsoft Dataverse

  1. Select Loans for Table name and click Show advanced options.

Show advanced options

  1. Enter rc_loannumber eq for Filter rows and select LoanNumber from the dynamic content pane.

enter details listed

[!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 + -).

  1. Add single quotes (‘) before and after LoanNumber

  2. Click + New step.

  3. Select Condition.

add the condition

  1. Click to select the first operand field, go to the dynamic content pane, and select the expression tab.

  2. Paste the expression below and click OK. This checks if any rows were returned.

empty(outputs(‘List_rows’)?[‘body/value’])

paste the expression listed

  1. Select is equal to for condition.

  2. Click to select the second operand field, go to the dynamic content pane, and select the expression tab.

  3. Type true and click OK.

add the true item

  1. Go to the If yes branch and click Add an action.

add an action in the yes branch

  1. Select Respond to a PowerApp or flow.

search for and select the Respond to a PowerApp or flow action

  1. Click + Add an output.

select add an output

  1. Select Yes/No.

  2. Enter LoanFound for title and click to select the value field.

  3. Go to the Dynamic content pane and select the Expression tab.

  4. Type false and click OK.

type false for the function and select ok

  1. Click + Add an output again.

  2. Select Text.

  3. Enter LoanID for title.

  4. Click on the value field, add an empty space.

place your curser in the empty space as described

  1. Click on the more actions button and select Rename.

in more actions, select rename

  1. Rename the step Not found response.

  2. Go to the If no branch and click Add an action.

add an action in the no branch

  1. Select Respond to a PowerApp or flow.

search for and select respond to a PowerApp of flow action

  1. Click + Add an output.

  2. Select Yes/No.

  3. Enter LoanFound for title and click to select the value field.

  4. Go to the dynamic content pane and select the Expression tab.

  5. Type true and click OK.

enter the value true for the function

  1. Click + Add an output again.

  2. Select Text.

  3. Enter LoanID for title.

  4. Click to select the value field, go to the dynamic content pane, and select the Expression tab.

  5. Paste the expression below and click OK. This gets the ID from the first row.

outputs(‘List_rows’)?[‘body/value’][0][‘rc_loanid’]

paste the expression as directed

  1. Click on the … more actions button and select Rename.

  2. Rename the step Found response.

  3. Click Save to save the flow.

save the flow

  1. Click Test.

test the flow

  1. Select Manually and click Test.

  2. Enter MC3747 for LoanNumber and click Run flow.

give the load number MC3747

  1. Click Done.

  2. Click to expand the response step.

  3. Make sure the output body matches your expectation.

verify the output

  1. You may close the flow

Exercise #2: Inspection Child flow

Task #1: Setup Machine connection

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Click + New and select More | Connection Reference.

in the solution select new connection reference

  1. Enter Desktop Flows for Display name, select Desktop flows for Connector, click on the Connection dropdown and select + New connection.

select new connection

  1. 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.

set the connections for the desktop flow

  1. Provide your username, password, and click Create. If your username doesn’t work try admin as the username.

provide user information

  1. Close the connection browser tab or window.

  2. Click on the Refresh connection button.

refresh the connection

  1. Select the connection you created and click Create.

select create

Task #2: Create child flow

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Click + New and select Automation | Cloud flow | Instant.

add a new instant flow automation to the solution

  1. Enter CF Manage Inspection Process for Flow name, select Manually trigger a flow, and click Create.

  2. Expand the trigger and click + Add an input.

  3. Select Text.

  4. Enter PropertyAddress and click + Add an input again.

enter details as listed

  1. Select Text.

  2. Enter LoanDrawID and click + Add an input one more time.

  3. Select Text.

  4. Enter Work. You should now have three input parameters. Click + New step.

enter details as listed

  1. Select Run a flow built with Power Automate for desktop.

search for and select Run a flow built with Power Automate for desktop

  1. Select Perform Site Inspection for Desktop flow and select Attended for Run Mode.

  2. Click on the WorkToInspect field and select Work from the dynamic content pane.

select work from the dynamic content pane

  1. Click on the PropertyAddress and select PropertyAddress from the dynamic content pane.

  2. Enter your name for Inspection account number.

enter text as described

  1. Click + New step.

  2. Search the connectors and actions for Parse JSON. Select the Parse JSON action which is part of the Data Operation connector.

select parse JSON

  1. Click on the Content field and select SitePhotos from dynamic content pane.

select SitePhotos from dynamic content pane

  1. 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 new step

  1. Select the HTTP action.

select HTTP action

  1. Select GET for Method, click on the URI field, and select url from the dynamic content pane.

select Get method

  1. Apply to each will be added automatically for you. Rename the Apply to each step Apply to each image.

  2. Click Add an action.

select add an action from the apply to each image step

  1. Select the Add a new row action from the Microsoft Dataverse connector.

search for and select Add a new row action

  1. Select Inspection Photos for Table name, click on the Name field, and select name from the dynamic content pane.

choose Inspection Photo and enter the details

  1. Rename the “Add a new row” step to Add inspection photo and click Show advanced options.

rename the step

  1. Enter rc_loandraws() for Loan Draw, place your cursor inside the parentheses, and select LoanDrawID from the dynamic content pane.

enter details shown

  1. Click on the Photo field, go to the dynamic content pane, and select the Expression tab.

  2. Paste the expression below and click OK.

    base64(body('HTTP'))

enter details shown

  1. Click + New step.

select add new step

  1. Select the Update a row action from the Microsoft Dataverse connector.

search for an select Update a row Microsoft Dataverse

  1. Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.

  2. Click Show advanced options.

show advanced options

  1. Click on the Inspected On field, go to the dynamic content pane, select the Expression tab, type utcNow() and click OK.

add time to the field

  1. Click on the Inspection Job field and select JobNumber from the dynamic content pane.

add job number field

  1. Select Inspection Completed for Status Reason and click Hide advanced options.

input status reason and hide advanced options

  1. Rename the step Update loan draw and click + New step.

  2. Select the Respond to PowerApp or flow action from the PowerApps connector.

search for and select Respond to PowerApp or flow

  1. Click + Add an output.

  2. Select Text.

  3. Enter InspectionStatus, click on the value field and select InspectionStatus from the dynamic content pane.

enter details as described

  1. Click + Add an output again.

  2. Select Text.

  3. Enter JobNumber, click on the value field and select JobNumber from the dynamic content pane.

enter details as described

  1. Click Save to save the flow.

  2. Click on the back arrow.

select back button

  1. Open the flow details.

open flow details

  1. Click Run.

  2. If prompted, select Manually and click Test again.

  3. Click Continue.

run the flo

  1. DO NOT navigate away from this page.

  2. Start a new browser instance and navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  3. Select Apps and launch the Loan Manager application.

launch the loan manager app

  1. Open the first loan record.

  2. Click Related and select Loan Draws.

drill into record details as described

  1. Click + New Loan Draw.

add a new loan draw

  1. Enter Test Draw for Name and click Save.

  2. Go to the URL and copy the id GUID. Paste this id into Notepad, you will need it in future steps.

get the url id as described

  1. 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.

follow the steps to run the flow

  1. Wait for the flow run to complete.

  2. Close the run flow pane.

  3. Go to the 28-day run history and click refresh until the flow run shows as Succeeded.

Wait for the succeeded message

  1. Go back to the Loan Manager application, click Related and select Inspection Photos.

Select the related photos

  1. You should see the inspection photos created by the flow.

Review the photos created by the flow

Exercise #3: Funding Child flow

Task #1: Create child flow

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Click + New and select Automation | Cloud flow | Instant.

  4. Enter CF Manage Woodgrove Funding Process for Flow name, select Manually trigger a flow, and click Create.

name your new flow

  1. Expand the trigger and click + Add an input.

select add input

  1. Select Text.

  2. Enter LoanNumber and click + Add an input again.

  3. Select Text.

  4. Enter LoanDrawID and click + Add an input again.

  5. Select Text.

  6. Enter RequestedAmount and click + Add an input again.

  7. Select Text.

  8. Enter InspectionJobID and click + Add an input again.

  9. Select Number.

  10. Enter RiskScore.

  11. You should now have five inputs. Click + New step.

review the steps and select new step

  1. Select the Run a flow built with Power Automate for desktop action.

Search for and select the Run a flow built with Power Automate for desktop action

  1. Select Woodgrove Funding Manager Draw for Desktop flow and select Attended for Run Mode.

  2. Click on the LoanNumber field and select LoanNumber from the dynamic content pane.

follow the steps for using the dynamic content pane

  1. Click on the RequestedAmount field and select RequestedAmount from the dynamic content pane.

  2. Click on the InspectionJobNumber field and select InspectionJobID from the dynamic content pane.

  3. Type Yes for BorrowerApproved.

  4. Click on the RiskScore field and select RiskScore from the dynamic content pane.

  5. Enter your name for Username, pass@word1 for Password.

  6. The run desktop flow should now look like the image below. Click + New step.

review the steps

  1. Select the Condition action from the Control connector.

  2. Click on the first operand and select FundingStatus from the dynamic content pane.

add details to the funding step

  1. Select is equal to for operator and enter Approved for the second operand.

  2. Go to the If yes branch and click Add an action.

add an action to the yes side

  1. Select the Update a row action from the Microsoft Dataverse connector.

select update a row for Dataverse

  1. Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.

select loan draw for table

  1. Click Show advanced options.

  2. Click on the Amount Funded field and go to the dynamic content pane and select the Expression tab.

  3. Paste the expression below and click OK.

    replace(outputs('Run_a_flow_built_with_Power_Automate_for_desktop')?['body/FundedAmount'], '$','')

paste the expression

  1. Click on the Funded On field, go to the dynamic content pane, and select the Expression tab.

  2. Type utcNow() and click OK.

add time field

  1. Click on the Funding Sequence Number field and select FundSequenceNumber from the dynamic content pane.

  2. Click on the Funding Transfer Number field and select FundTransferNumber form the dynamic content pane.

  3. Click on the RiskScore field and select RiskScore form the dynamic content pane.

  4. Select Funding Approved for Status Reason and click Hide advanced options.

set status reason

  1. Rename the step Update for approved.

  2. Go to the If no branch and click Add an action.

add an action on the no branch

  1. Select the Update a row action from the Microsoft Dataverse connector.

select update a row

  1. Select Loan Draws for Table name, click on the Row ID field and select LoanDrawID from the dynamic content pane.

select loan draws

  1. Click Show advanced options.

  2. Select Funding Denied for Status Reason and click + New step.

set status reason

  1. Select the Respond to PowerApps or flow action from the PowerApps connector.

select respond to PowerApp or flow action

  1. Click + Add an output.

  2. Select Text.

  3. Enter FundingStatus, click on the value field and select FundingStatus from the dynamic content pane.

enter details as described

  1. Click Save and wait for the flow to be saved.

  2. Click Test.

  3. Select Manually and click Test again.

  4. Click Continue.

  5. 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.

run the flow with the provided details

  1. 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

  1. Navigate to https://admin.microsoft.com/ and click Show all.

in the admin portal, select show all

  1. Go to the Admin centers area and select Exchange.

select exchange

  1. In the left side menu under Recipients select Mailboxes.

  2. Click + Add a shared mailbox.

add a shared mailbox

  1. Enter Funding for Display name, Funding for Email address, select your domain, and click Create.

enter details as described

  1. Click Add users to this mailbox.

add users to mailbox

  1. Click + Add members.

  2. Select your user and click Save. You may add other users to the shared mailbox.

manage mailbox members

  1. Click Confirm.

  2. Close the shared mailbox pane.

Task #2: Create flow

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Locate and open the CF Manage Inspection Process child flow.

locate the child flow

  1. Go to the Run only users section and click Edit.

edit users

  1. Select the desktop connection you created and click OK on the popup.

  2. Click Save.

select desktop flows

  1. Click on the browser back button.

  2. Locate and open the CF Manage Woodgrove Funding Process child flow.

open the next child flow

  1. Go to the Run only users section and click Edit.

  2. Select the desktop connection you created and click OK on the popup.

  3. Click Save.

  4. Click on the browser back button.

  5. Click + New and select Automation | Cloud flow | Automated.

select automated

  1. Enter Process Construction Funding Request for Flow name, select the When a new email arrives in a shared mailbox trigger, and click Create.

name and create the flow

  1. Select the Funding shared email you created for Original Mailbox Address, select Inbox for Folder, and click Show advanced options.

  2. Select Yes for Include attachments and click on the button of the trigger.

select the ellipses

  1. Select Rename.

  2. Rename the trigger to When a new funding request email arrives.

  3. Click + New step.

  4. Select the Run a Child Flow action from the Flows connector.

select run a child flow action

  1. Select CF Lookup Loan for Child flow.

  2. Click on the LoanNumber field, go to the dynamic content pane, and select Subject.

enter details as described

  1. Rename the step Lookup loan number.

  2. Click + New step.

  3. Select the Condition action from the Control connector.

  4. Click to select the first operand field, go to the dynamic content pane, and select LoanFound.

enter details as described

  1. Select is equal to for the operator and type True for the second operand field.

  2. Rename the condition Check if loan number found.

  3. Go to the If no branch and click Add an action.

  4. Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.

select send email from shared mailbox v2

  1. Click on the Original mailbox Address, click Add dynamic content and select To from the dynamic content pane.

enter details as described

  1. Click on the To field, click Add dynamics content and select From from the dynamic content pane.

  2. Type Loan number not found for Subject.

  3. Type Loan # Body and select Subject from the dynamic content pane.

enter details as described

  1. Add not found, contact your bank. to the body.

  2. Rename the reply Send loan not found email and click Add an action.

enter details as described

  1. Select the Terminate action from the Control connector.

select terminate action

  1. Select Succeeded for Status.

  2. Click + New step.

select new step

  1. Select the Add a new row action from the Microsoft Dataverse connector.

select add a new row

  1. Select Loan Draws for Table name.

  2. Enter Loan draw for Name and click Show advanced options.

enter details as described

  1. Enter 80000 for Amount Requested.

  2. Type rc_loans() for Loan (Loans), place your cursor inside the parentheses, and select LoanID from the dynamic content pane.

enter details as described

  1. Rename the step Create new loan draw row.

  2. Click + New step.

  3. Select the Run a Child Flow action from the Flows connector.

  4. Select CF Manage Inspection Process for Child flow.

  5. Enter 123 Main Street for PropertyAddress.

  6. Click on the LoanDrawID field and select Loan Draw from the dynamic content pane.

enter details as described

  1. Enter Test work item for Work.

  2. Rename the child flow Run inspection process and click + New step.

rename the flow and select add new step

  1. Select the Run a Child Flow action from the Flows connector.

  2. Select CF Manage Woodgrove Funding Process for Child flow.

  3. Click on the LoanNumber field and select Subject from the dynamic content pane.

  4. Click on the LoanDrawID field and select Loan Draw from the dynamic content pane.

  5. Enter 80000 for RequestedAmount.

  6. Click on the InspectionJobID field and select JobNumber from the dynamic content pane.

  7. Enter 55 for RiskScore.

  8. Rename the child flow Run funding process. Click Save.

  9. Click + New step.

click new step

  1. Select the Condition action from the Control connector.

  2. Click on the first operand and select FundingStatus from the dynamic content pane.

enter details as described

  1. Select is equals to for operator and enter Approved for the second operand.

  2. Rename the condition Check approval status.

  3. Go to the If yes branch and click Add an action.

add an action on the yes branch

  1. Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.

  2. Click on the Original Mailbox Address field, click Add dynamic content and select To from the dynamic content pane.

  3. Click on the To field, click Add dynamics content and select From from the dynamic content pane.

  4. Enter Draw Approved for Subject.

  5. Type Your draw for in the Body and select Amount Funded from the dynamic content pane.

enter details as described

  1. Add was approved to the body.

  2. Rename the step Send approved draw email.

  3. Go to the If no branch and click Add an action.

add an action to the no branch

  1. Select the Send an email from a shared mailbox (V2) action from the Office 365 Outlook connector.

  2. Click on the Original Mailbox Address field, click Add dynamic content and select To from the dynamic content pane.

  3. Click on the To field, click Add dynamic content and select From from the dynamic content pane.

  4. Enter Draw was not approved for Subject.

  5. Type Your draw for in the Body and select Amount Funded from the dynamic content pane.

  6. Add was not approved, please contact bank. to the body.

  7. Rename the step Send draw not approved email.

  8. Click Save and wait for the flow to be saved.

save the flow

Task #3: Test flow

  1. Click Test.

  2. Select Manually and click Test again.

  3. Send an email with the subject MC3747 from your email to the Funding shared email you created (Funding@yourdomain.onmicrosoft.com).

  4. Wait for the flow to get triggered. Do not interact your computer while the flow is running.

  5. The flow should run successfully.

review the tested flow

  1. You should receive an email with the subject Draw Approved.