© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
S. Prakash PradhanPower Platform and Dynamics 365 CE for Absolute Beginnershttps://doi.org/10.1007/978-1-4842-8600-5_4

4. Working with Power Automate

Sanjaya Prakash Pradhan1  
(1)
Ganjam, Odisha, India
 

Microsoft Power Automate (previously known as Flow) helps you create automated workflows between your favorite cloud and on-premise apps. It provides services to synchronize files, get notifications, collect data, and more.

Power Automate is an important pillar of Microsoft Power Platform ecosystem that builds robust automation over cloud apps.

These days, most apps are available in the cloud, although some are still available from on-premise environments. Integrating these cloud systems is tricky, and using a no-code, less-code platform to do this is a real benefit. Power Automate solves these integration automation needs, regardless of the datasource’s location. Using connectors, you can connect practically any datasource to automate your business needs.

Power Automate’s Building Blocks

Power Automate has three building blocks. These are triggers, connectors, and actions. Every Flow must have a trigger and one or more connectors and actions.

Table 4-1 explains the concepts of triggers, connectors, and actions.
Table 4-1

Triggers, Connectors, and Actions

Building Block

Description

Triggers

Events that initiate a flow instance. For example, running a flow on-demand from a button click, or running a flow when a file is uploaded to SharePoint.

Connectors

Adaptors that communicate with other products or services. For example, if you want to create a file in OneDrive, you need a OneDrive Connector. If you want to read data from Dynamics 365, you can create a connector to the Dataverse. Connectors require authentication. You must have a subscription to the service you want to connect from Power Automate.

Actions

Operations that you define so that the Flow will perform them. For example, creating a file in SharePoint, deleting a record from the Dataverse, sending an email, etc.

Features of Power Automate

Automate quickly and more securely

With Power Automate, anyone can create automated processes using flows. You can automate repetitive, monotonous operations with ease, using low-code, drag-and-drop tools and hundreds of pre-built connectors.

Boost efficiency

With process adviser, you can record and visualize your end-to-end processes while getting guided advice for developing flows and detailed insights that take the guesswork out of deciding what to automate.

Enhance workflows with AI

With AI Builder, you can make your automation even smarter. Use document automation to quickly process forms, handle approvals, identify photos and text, and generate with pre-built models.

Connectors in Power Automate

A connector is a wrapper or proxy that allows an underlying service to communicate with Microsoft Power Automate, Microsoft Power Apps, and Azure Logic Apps. It allows users to link their accounts and use a library of pre-built actions and triggers to create apps and processes.

Microsoft has 200+ connectors you can use to automate business process and flows, but if a specific connector is not available, you can create your own custom connector. Figure 4-1 displays a list of connectors.

A webpage exhibits the rows of 8 connectors under the Popular Connectors, Recently added connectors, and Independent Publisher connectors section. All have Premium tags, except for the Office 365 Outlook, OneDrive for Business, Office 365 Users, SharePoint, Twitter, Notifications, and R S S. A search bar and All connectors with a drop-down option are located at the top.

Figure 4-1

Connector list

Types of Flows and Uses

There are five types of flow you can create. The type of trigger decides the type of flow. These are explained in Table 4-2.
Table 4-2

Types of Flows

Type

Description

Automated Cloud Flow

Triggered by designated events.

Instant Cloud Flow

Triggered manually as needed.

Scheduled Cloud Flow

You can choose when and how often it runs.

Desktop Flow

Automated processes on your desktop environment. Leverage Robotic Process Automation (RPA).

Business Process Flow

Guides users through a multi-step process.

Configure an Automated Cloud Flow

In this example, you see how to automatically trigger a Power Automate flow when an event occurs in the Dataverse.

Business Scenario

In this example, you see how to send an email to your manager when Lead annual revenue is more than $5,000 for notification purposes.

Solution

This solution requires a Power Automate configuration with an event trigger. The following steps show how to configure the flow.

Step 1: Use the Solution to Create a Flow

Open the solution and click the Add New option. Choose Automation then the Cloud Flow with Automated option. Figure 4-2 shows this process.

A window exhibits four highlighted sequenced steps. After clicking the New option at the top, select the second option, Automation, which reveals a list of four options, namely, Cloud flow, Custom connector, Desktop flow, and Process. Click the first option, and then select Automated above Instant and Scheduled to complete the task.

Figure 4-2

Adding an automated flow to the solution

Now specify a name and a trigger. Call it Send Email to Manager for Lead more than 5000 USD revenue. Call the trigger Dataverse and, in the list, choose When a row is added, modified, or deleted trigger. You can learn more about the Dataverse connectors from Microsoft at https://docs.microsoft.com/en-us/connectors/commondataserviceforapps/. Click Create. Figure 4-3 shows the trigger and the name of the flow.

A window with Build an automated cloud flow text above an illustrated laptop and additional text. On the right, the Flow name field has Send Email to Manager for Lead more than 5000 U S D revenue and the dataverse entry in the Choose your flow's trigger search bar highlights a Microsoft Dataverse - When a row is added, modified, e t c.

Figure 4-3

Adding an automated flow to the solution

Step 2: Configure the Trigger

You will notice that the trigger is identified on the designer. Now set Change Type to Modified, Table Name to Leads, and Scope to Organization. Figure 4-4 shows the trigger.

A dialog box is titled When a row is added, modified, or deleted. Change type is set to Modified, Table name is set to Leads, and Scope is set to Organization. To the left is the Show advanced options. New step and Save buttons are located below the dialog box.

Figure 4-4

The Dataverse trigger

Step 3: Add a Filter Expression to the Trigger

Now you’ll add a filter condition to the trigger to filter and trigger only when the annual revenue is more than $5,000. To do this, click the Show Advanced options of trigger.

In the Filter Rows box, specify annualrevenue gt 5000. Make sure to use the logical name of the field you are trying to compare with to the value. This expression is called an OData expression and it defines a filter condition while querying the Dataverse data. To learn more about OData syntax, see https://www.odata.org/documentation/odata-version-2-0/uri-conventions/. See Figure 4-5.

A dialog box is titled When a row is added, modified, or deleted. Change type is set to Modified, Table name is set to Leads, and Scope is set to Organization. A highlighted Filter rows option is set to annual revenue g t 5000. Select columns, Delay until, and Run as fields have directions. Hide advanced options button is on the lower left. New step and Save buttons are located below the dialog box.

Figure 4-5

Adding a filter condition

Step 4: Get the Current User Manager

Click +New Step and search Get My Profile. This creates a connection to Office 365 Users so that you can use Get My Profile. See Figures 4-6 and 4-7.

A window of Office 365 Users. The search bar exhibits two sections of results under Triggers and Actions. Under the latter are Get direct reports V 2, Get manager V 2, and Get my profile V 2, which has a hand cursor.

Figure 4-6

Get the user profile

A window of Get my profile V 2. Below is the Show advanced options button. Above the window is a downward arrow.

Figure 4-7

The get user profile step

Click +New Step and search for the Get Manager trigger. Once you type get manager, it will display related triggers and actions that you can use. Figure 4-8 shows the Get Manager trigger.

A window is titled, Choose an operation. The get manager entry in the search bar is highlighted. Under the All tab below the search bar is the highlighted Office 365 Users. From the Actions tab at the bottom is the highlighted Get manager V 2 Office 365 Users above the Premium Get Request Incident Document List Easy Vista Service Manager.

Figure 4-8

The Get Manager trigger and action

Select the Get Manager action. This will sign in automatically and create a background connector with the Office 365 Users application using the current login user credential.

This Get Manager action requires a user email so that it can get the manager information.

In the User box, assign the Mail attribute from the Dynamics content so that it will pass the current user profile mail into the Get Manager action for which it will read manager information. This Mail attribute will be available in the Dynamic panel because of the Office 365 Users connector. To learn more about the Office 365 Users connector, see https://docs.microsoft.com/en-us/connectors/office365users/. See Figure 4-9.

A window of Get manager V 2. User U P N has Mail as its highlighted entry. On the lower right is the Add dynamic content option. Clicking it reveals a separate window with Dynamic content and Expression tabs above a search bar. Under the former tab are entries such as the highlighted Mail.

Figure 4-9

Assign a user to Get Manager

Step 5: Send an Email

Now you can send a well formatted email to the manager. After the Get Manager step, add a new step called Send Email Using Gmail connector. Assign features to the subject body as needed using the Dynamic content panel. If the Dynamic content panel is not visible, click the blue icon labeled Add Dynamic Content. It will open the Dynamic panel. The Dynamic content panel displays the dynamic values that are part of the previous steps associated with different connectors. Figure 4-10 shows the process of assigning dynamic contents to the email send step.

A window of Send email V 2. To is set to Mail. Subject is set to New Lead created more than 5 k Annual Revenue and First Name. Body has Dear, Display Name, and content. Clicking the Add dynamic content option reveals Dynamic content tab entries such as Display Name, Given Name, and I d. Attachment fields are located below.

Figure 4-10

Send an email and adding dynamic content

Now if you create a lead in the Dataverse and update the annual revenue with more than $5,000, the system will send an email to your manager from your Gmail Account. You can use the Outlook connector to send email as well.

Configure an Instant Cloud Flow

Instant flow creates a mobile button to click on demand and the actions will be performed as per the flow design. Say you want to send an email with an attachment to a person on demand via a button click.

Create an Instant Flow by Navigating to Power Automate

Open office.com, click All Apps, and choose Power Automate. You can also create the instant flow inside a solution, but it will not display the button on mobile devices. Figure 4-11 shows the Power Automate link.

A webpage exhibits the various Office applications under the Apps section. Power Automate is highlighted and is marked by a hand cursor. Other applications are OneDrive, Excel, OneNote, Power Apps, Word, PowerPoint, SharePoint, Admin, and Lists. The option to view All apps is located below.

Figure 4-11

Power Automate link

On the Power Automate screen, click Environment and choose the correct environment. Figure 4-12 shows the environment change option.

A window with the title bar has the text soft chief default with various icons. On the right side is an Environments-labeled panel, followed by a search bar and a checked Development option just above the soft chief default text.

Figure 4-12

Power Automate environment change

Click + Create and choose Instant Cloud Flow. Figure 4-13 shows the instant flow option.

A window of Power Automate. On the left panel is the highlighted Create option. The main window exhibits Three ways to make a flow with five options under the Start from blank section of which Instant cloud flow triggered manually as needed is highlighted. Below is the Start from a template section with four options under the Top picks tab.

Figure 4-13

Instant flow option

Call this Send Email with File and, from the connector list, choose Manually Trigger a Flow. Figure 4-14 shows the button flow option.

A dialog box with Build an instant cloud flow text above an illustrated laptop with additional text. On the right, the Flow name field has Send Email With File entry and Choose how to trigger this flow highlights the checked Manually trigger a flow, Flow button for mobile out of 7 observable options. Skip, Create, and Cancel buttons are on the lower right.

Figure 4-14

Choose the button flow

Click Create. This will open the Power Automate designer window. Expand the trigger and add four input parameters—two text type parameters, one email type, and one file type. Figure 4-15 shows the instant flow parameters.

A window is titled as Manually trigger a flow. From left to right and top to bottom, the labels are Subject, Please enter your input, Message, Please enter your input, Email, Please enter an e-mail address, File, and Please select file or image. Add an input option is located below.

Figure 4-15

Parameters

Click + New Step and search for the Gmail connector. Choose the Send Email action. To learn more about Gmail connector, see https://docs.microsoft.com/en-us/connectors/gmail/. Figure 4-16 shows the Gmail connector.

A title bar with the Manually trigger a flow text connects to a window labeled Gmail through a downward arrow. The latter has a search bar with two sections of results under Triggers and Actions. Under Actions are Reply to email V 2 and Send email V 2. The latter is highlighted and has a hand cursor.

Figure 4-16

The Gmail connector

Click the Connect button, which will open the Gmail Login screen for authentication. Provide authentication and click OK. Using the Dynamic content panel, assign the To, Subject, and Body of the Gmail Send steps from the Parameter list. Figure 4-17 shows the process of assigning values to fields.

A window is labeled as Send email V 2. The Email, Subject, and Message entries in To, Subject, and Body fields above Attachments fields are highlighted and are pointed by arrows from the opened Dynamic content tab next to the Expression tab.

Figure 4-17

Assigning values from the Dynamic panel

For the File option, provide document.pdf for the Attachment Name and File for the dynamic content panel. For Content-Type, specify pdf. Figure 4-18 shows the file field assignment.

A window exhibits the Attachments fields. Attachments Name 1, Attachments Content, and Attachments Content have highlighted document dot p d f, File, and p d f entries respectively. An arrow from the panel with Dynamic content and Expression tabs points to the File entry. The search bar, under the former, exhibits the File result under Manually trigger a flow.

Figure 4-18

File assignment

Now save Power Automate. Open your mobile device and install the Power Automate app from Google Play Store or Apple App Store. Once it’s installed, open the app and log in using your credentials. Follow the site at https://us.flow.microsoft.com/en-us/mobile/download/ to download the app and then install it. Select the correct environment. Now if you click the link at the bottom-center of the app, you will see the flow. Clicking the Send Email with File button will prompt you to provide a subject, message, email address, and a file to upload. Once you click Done, the email will be sent to the respective email account.

Configure a Scheduled Cloud Flow

Scheduled cloud flows can be used to run business logic repeatedly in a specific time interval. For example, if you want to run a flow everyday 10AM, you can configure scheduled cloud flow.

Let’s consider a business scenario. You want to send an attendance email every day at 10AM to all the students at your school. Follow these steps to configure Power Automate to do this.

Step 1: Create a Scheduled Flow by Navigating to Power Automate

Navigate to your Power Apps solution and open it. Click the + Add New command button and choose Automation ➤ Cloud Flow ➤ Scheduled. Figure 4-19 shows the process of adding a scheduled flow inside a solution.

A webpage of Power Apps. The main page exhibits the contents of the Objects option from the left panel. Option All is selected. The four sequenced steps are as follows. Selecting the New option reveals Automation as the second option. Clicking it reveals Cloud flow and another click exhibits the Scheduled option, the third out of three options.

Figure 4-19

Adding a scheduled flow

Call this Send Reminder for Attendance Fillup. Select a starting date and time. Configure the Repeat Every option in the next screen. Figure 4-20 shows the recurrence configuration.

A dialog box with Build a scheduled cloud flow text above an illustrated laptop with additional text and bulleted entries. On the right, four steps are marked. Send Reminder for attendance fill-up in Flow name, Run this flow starting April 4, 2022, at 10 in the morning, and Repeat daily. Skip, Create, Cancel buttons are on the lower right where Create option is selected.

Figure 4-20

Configuring recurrence

Click Create. This will open the Flow Designer, where you can add actions.

Step 2: Connect to the Dataverse to Get Students

Click +New Step. Because you want to send the email to all students from the Dataverse, you need the Dataverse connector. You must also choose the List Row action to read all student records from the Dataverse. Figure 4-21 shows the List Row action of the Dataverse. You can learn more about List Row action from the Dataverse connector topic at https://docs.microsoft.com/en-us/connectors/commondataserviceforapps/.

A title bar with the Recurrence text connects to a window labeled List rows through a downward arrow. The latter has Students as its chosen Table name. Show advanced options is located on its lower left.

Figure 4-21

List Row action of the Dataverse

In the next step, add a new step and choose Control Connector ➤ Apply to Each Action. In the Select an Output from Previous Steps option, choose a value from the Dynamic content panel. Learn more about the loops action at https://docs.microsoft.com/en-us/power-automate/apply-to-each. Figure 4-22 shows how to add a value object to a loop step.

A window of Apply to each. The Select an output from previous steps has a highlighted value as its entry. On the lower right is an opened panel with Dynamic content and Expression tabs. The search bar, under the latter, has a text value and a result of value under List rows. An arrow connects the similar entries.

Figure 4-22

Adding a value object to a loop

Inside Apply to Each Action, add a new step. Choose the Gmail connector and select the Send Email action. Specify Email in the To field using the Dynamic content panel. In the Subject field, specify the Reminder – Attendance Filling for the Day static value.

In the Email body, specify some content as you wish. For example, “Dear Student, please fill in the attendance now.” Figure 4-23 shows how to assign email fields.

Two superimposed windows are labeled Apply to each and Send email V 2. The former has value as its entry for Select an output from previous steps. The latter has highlighted Email, Reminder Attendance filing for the day, and content for To, Subject, and Body fields respectively.

Figure 4-23

Assigning email fields

Save the flow. Now the scheduled flow is ready. It will run every day at 10AM, as scheduled. You can check the run status using Details page of the Flow. Figure 4-24 shows the details option for flow.

A webpage of Power Apps. The main page exhibits the contents of the Objects option under School Management Solution from the left panel. Cloud flows option is selected. Send Reminder for attendance fill-up is checked and highlighted. The Details option, from the context menu of the former, is also highlighted and has a hand cursor.

Figure 4-24

Details option for the flow

In the Details page, you will see the Run History of Power Automate. Figure 4-25 shows the details run history of the flow.

A window exhibits the contents of Attendance mailer to students daily for filling the attendance from Flows. The left side has Details and highlighted 28-day run history section. The latter has dates under Start, seconds under Duration, and data under Status. On the right are Connection References, Owners, Solutions, and Process insights sections.

Figure 4-25

Details option for the flow

This is how you create a scheduled flow for your business needs.

Configure a Business Process Flow

Business Process Flows (BPF) guide users to follow a predefined process with multiple stages in order to complete a specific task. For example, for a process called Student On-Boarding, your business might follow specific stages so that all users follow the same steps to complete the process. For more about BPF, visit https://docs.microsoft.com/en-us/power-automate/business-process-flows-overview.

A typical business process flow could be student on-boarding. Figure 4-26 shows details for this flow. The stages may include the following:
  1. 1.

    Capture personal details

     
  2. 2.

    Capture communication details

     
  3. 3.

    Capture enrolled courses

     
  4. 4.

    Record payment details

     

A block diagram of business process flow. The Personal Details block connects to Communication Details. The latter then connects to an Enrolled Courses, which in turn connects to a Record Payment block.

Figure 4-26

Details option for this flow

To configure a Business Process Flow (BPF), use the following steps.

Step 1: Use the Solution to Create a BPF

Open the Power Apps solution and choose + New ➤ Automation ➤ Process ➤ Business Process Flow. Figure 4-27 shows how to add a BPF inside a solution.

A webpage of Power Apps. The main page exhibits the contents of the Objects option from the left panel. Option All is selected. The four sequenced steps are as follows. Selecting the New option reveals Automation as the second option. Clicking it reveals Process and another click exhibits the Business process flow option, the second out of 3 options.

Figure 4-27

Adding a BPF inside a solution

Once you click the option, it will open a side panel where you can specify a display name and table for which you are going to create the BPF. For example, the “student on-boarding” BPF is connected to the Student table.

Choose Student from the table. The Name field will automatically fill in per the Display Name, but in all lowercase. Every BPF creates a table inside the Dataverse to store the stage and data step information that’s used in the BPF. Figure 4-28 shows the process of adding the BPF information.

A webpage exhibits a panel on the right side labeled New business process flow. The Display name field has Student On-boarding entry, Name field in soft underscore has student on boarding entry, and Table has a selected Student option. Create and Cancel buttons are on the lower left side of the panel where Create is selected.

Figure 4-28

BPF information

Click Create. The BPF Designer will open in a new window. Use the right side component panel and drag four stages to the designer canvas. Four stages are required. Every stage contains one or more data steps, which point to the column of the specific table to which the stage is connected. Figure 4-29 shows the BPF designer.

The B P F Designer window. The text on the upper left reads Student Onboarding with various options. Three sets of Student New Stage labeled entries are in the center. On the right is an opened Components tab, where the Stage content under the Flow section is being dragged to the center and the cursor highlights the text, This is a valid hit area to add the new tile.

Figure 4-29

The BPF designer

You can add different components inside a stage, including:
  • Data steps

  • Workflows

  • Action steps

  • Flow steps

You can also add conditional branches inside a BPF for complex business processes. Read more about branching in BPF at https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/enhance-business-process-flows-branching?view=op-9-1.

Step 2: Edit the Stages

Click First Stage and specify a name for the stage. Choose a category and click Apply. Notice that the first stage Entity option points to Student and is read-only. That means you cannot change this First Stage entity. Figure 4-30 shows the process of adding stages to the BPF.

A zoomed section of the B P F Designer window. Student New Stage is highlighted and has an arrow pointing to the highlighted Stage panel on the right. Display Name is set to Personal Details, Category is set to Qualify, and Entity has an unhighlighted Student text where an arrow cursor is observed. Apply button is highlighted next to the Discard button.

Figure 4-30

Adding stages to the BPF

Click the Details option in the First Stage and choose Data Steps #1. From the Properties panel, specify a data step name and select Data Field for the Name. You can select the Required flag if you want the data step to be mandatory. Users cannot move to the next stage until any mandatory data steps are complete. Click Apply. Figure 4-31 shows the process of adding a data step inside a stage.

The B P F Designer window. The highlighted Student New Stage entry has Details button and Data Step hash 1 New Step under Steps 1 section. An arrow points to the highlighted Data Step panel, where Step Name is set to Name, Data Field is set to Name, Required is checked, and Sequence is set to 1. An arrow then points to the Apply button.

Figure 4-31

Adding a data step inside a stage

Repeat this step to add multiple data steps. Use the Component panel and the drag-and-drop operation. Figure 4-32 shows the drag-and-drop process.

A zoomed section of the B P F Designer window. The panel on the right exhibits an opened Components tab with Flow and Composition sections. Under the latter, Data Step is highlighted and is dragged to the Student Personal Details rectangle entry under Data Step hash 1 Name.

Figure 4-32

Dragging and dropping data steps

After you add more data steps, the first stage will look like Figure 4-33.

A zoomed section of the B P F Designer window. The Student Personal Details entry exhibits Data Step hash 1 Name, Data Step hash 2 Birth Date, and highlighted Data Step hash 3 Gender under Steps 3 section and above Triggered Process 0.

Figure 4-33

The final look of the first stage

Click the second stage and give it a name and a category and then set Entity to Student. Click Apply. Note that you can modify the Entity dropdown from the second stage onward. You are capturing communication details for the student, so choose Student as the Entity in this stage also. Figure 4-34 shows the process of adding a new stage.

A zoomed section of the B P F Designer window. The Student Communications Details entry is highlighted. On the right is a highlighted panel labeled Stage. Display Name is set to Communication Details, Category is set to Qualify, and Entity is set to Student. The Apply button next to the Discard button is surrounded by a dashed rectangle.

Figure 4-34

Adding a new stage

Keep adding data steps inside the second stage. The completed second stage will look like Figure 4-35.

A zoomed section of the B P F Designer window. The Student Communication Details entry exhibits Data Step hash 1 Mobile Number and highlighted Data Step hash 2 Email under Steps 2 section and above Triggered Process 0.

Figure 4-35

Second stage, final look

The third stage should connect to the Student Registered Course entity. Make sure to choose Relationship for the Student in the last dropdown. Click Apply. Figure 4-36 shows the stage properties.

A zoomed section of the B P F Designer window. The Student New Stage entry is highlighted and has an arrow cursor with a floating text box. The right panel has highlighted Enrolled Course entry under Display Name, Student Registered Courses, Student entry of Communication Details Student under Relationship, and an Apply button below is selected.

Figure 4-36

Stage properties

The final version of the third stage will look like Figure 4-37.

A zoomed section of the B P F Designer window. The Student Registered Courses Enrolled Course entry exhibits Data Step hash 1 Course, Date Step hash 2 Course Start Date, and highlighted Data Step hash 3 Student under Steps 3 section and above Triggered Process 0.

Figure 4-37

Final look of the third stage

The fourth stage points to the Student Payment entity. After you add the necessary data steps, this stage will look like Figure 4-38.

A zoomed section of the B P F Designer window. The Student Payment Record Payment entry exhibits Data Step hash 1 Total Amount, Data Step hash 2 Due Date, Data Step hash 3 Student, and Data Step hash 4 Terms under Steps 4 section and above Triggered Process 0.

Figure 4-38

Final look of the fourth stage

After adding all these stages and their data steps, validate and save the BPF. Now activate the BPF by clicking the Activate button. Figure 4-39 shows the final look of this BPF.

A zoomed section of the B P F Designer window. Student Personal Details with three steps, Student Communication Details with two steps, Student Registered Courses Enrolled Courses with three steps, and Student Payment Record Payment with four steps are linked. The details of the first entry are opened, exhibiting Name, Birth Date, and Gender.

Figure 4-39

Final look of the BPF

To test this BPF, navigate to Power Apps and open the Apps area. Choose the model-driven app of your choice, where the Student table is added to the sitemap. For this example, it’s Student App. Click School Management and choose Edit. Figure 4-40 shows the Edit the Model-Driven App option.

A webpage of Power Apps. The main page exhibits the contents of the Apps option from the left panel. School Management is selected and is highlighted under the Name column. The Edit button, above Play and Share on the list covers the Modified column entries and is highlighted. The third column is labeled Owner with Sanjay Prakash entries.

Figure 4-40

Edit the model-driven app option

This will open the Model App Designer window. Click Business Process Flow Area and select the BPF from the list. Unselect the other BPF. Figure 4-41 shows the BPF added to the model-driven app.

A zoomed view of the Model App Designer window. The highlighted Business Process Flow Area is above five Dashboards with entries of All. On the right panel is the opened Components tab with a highlighted and checked Student Onboarding entry.

Figure 4-41

Adding the BPF to the model-driven app

Now save and publish the model-driven app. Click the Play button on the top-right corner.

The Student App will open. Click the Students sub-area and click the +New command to open a new form for the student.

Now you will see that the BPF is available on the top of the form. The BPF will display with all stages you designed. All these stages remain inactive until you visit and take action on every required data step.

To start the BPF, you need to first save the student record by providing the mandatory values; then you can work with the BPF.

Provide the student’s mandatory fields and click Save. If you then click the First Stage, you will see the data steps and you can specify data step values and click the Next Stage button. Figure 4-42 shows the BPF in stage 1.

A window of the contents of the Student App under the Students section on the left panel. Student On-boarding, Active for less than one minute status is highlighted. Encircled steps are Personal Details, with Name and Gender filled out except for Birth Date, Communication Details, Enrolled Courses, and Record Payment. The General Info tab is opened.

Figure 4-42

The BPF in stage 1

Once you click Next Stage, the first stage will be complete. You’ll navigate to the second stage. Figure 4-43 shows the BPF in stage 2.

A zoomed section on the Student App webpage. The Student Onboarding Active for less than one minute status is on the upper left. Two out of four steps are encircled. The Communication Details section, the second step, has its Mobile Number and Email fields filled out. The Next Stage button underneath is highlighted. The General Info tab is opened.

Figure 4-43

BPF in stage 2

Complete the second stage and click Next Stage. This will show you a message that no records are found, as the student enrolled course record has not been created. Click +Create. This will open a new form to capture the course information for the student. Figure 4-44 shows the BPF in stage 2, notification.

A zoomed section on the Student App webpage. The user is on the Communication Details section just before the Enrolled Course. Mobile Number and Email fields are filled out. The Next Stage button underneath exhibits an empty space labeled Select Student Registered Courses, where Create option on the lower left is highlighted and has a hand cursor.

Figure 4-44

BPF in stage 2. notification

From the new course enroll form, provide the mandatory values and click Save. Now you will find Next Stage button. Figure 4-45 shows the BPF in stage 3.

A zoomed section on the Student App webpage. The user is on the Enrolled Course section after completing Personal Details and Communication Details. The Course is set to Dynamics 365 C E, the Course Start Date is on June 4, 2022, at 8 in the morning, and the Student option is set to Ramnath Kumar. The General tab is opened.

Figure 4-45

BPF in stage 3

Now click the + Create option to create a new payment record for the student. Figure 4-46 shows the BPF in stage 4.

A zoomed section on the Student App webpage. The user is on the Record Payment section after completing Personal Details, Communication Details, and Enrolled Course. The total amount is set to 400 dollars, Due Date is on May 4, 2022. The student is Ramnath Kumar, and the Terms option is set to 1. The General tab along with Student Info is opened.

Figure 4-46

BPF in stage 4

Click Save. The Finish button appears for the last stage. Click Finish to complete the student on-boarding process. Figure 4-47 shows the BPF in the final stage.

A zoomed section on the Student App webpage. The user is in the final stage where inputs are needed in the Record Payment section after completing Personal Details, Communication Details, and Enrolled Course. The total amount is set to 400 dollars, Due Date is on May 4, 2022. The student is Ramnath Kumar, and the Terms option is set to 1. The finish button is located below.

Figure 4-47

The BPF in the final stage

Now the BPF is complete. Figure 4-48 shows the completed BPF.

A zoomed section on the Student App webpage. The name Ramnath Kumar is above Student Onboarding status on the upper left. Below are General Info, Communication, and Related tabs. The Roll number is on the upper right. Personal Details, Communication Details, and Enrolled Course linked circles have checkmarks, while Record Payment has a flag icon.

Figure 4-48

The completed BPF

This way, users can ignore the complexity of tables and fields and simply follow the predefined stages to complete this business process.

You can enable BPF for specific security roles by using the Edit Security Role on the BPF Designer. You can read more about BPF and its security at https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/business-process-flows-overview?view=op-9-1.

Configure a Desktop Flow

Desktop Flows are designed using Power Automate Desktop. Desktop Flows are also called Robotic Process Automation (RPA) flows. You can use them to configure automation for desktop and web application tasks.

For example, if you want to download an Excel sheet from a website, extract data from the Excel sheet, and put it in a file, you can use the Desktop Flow. Or if you want to back up certain folders on a regular basis, you can use the Desktop Flow.

You can use Desktop Flow in lots of real-world scenarios. To create Desktop Flows, download Power Automate Desktop. For more details about Desktop Flow, visit https://docs.microsoft.com/en-us/power-automate/desktop-flows/create-flow.

Log in to flow.microsoft.com using your credentials. Choose the correct environment. Figure 4-49 shows how to change the environment.

A webpage with a highlighted Power Automate label. On the upper right are the stacked texts that read Environments, Development next to an icon. The panel on the right is labeled Environments. The Development option is checked and is highlighted below a search bar and above the soft chief default.

Figure 4-49

Changing the environment

Click + Create and choose Desktop Flow. Figure 4-50 shows the Desktop Flow option.

A zoomed section of the Power Automate webpage with Automated cloud flow, Instant cloud flow, Scheduled cloud flow, and Desktop flow. The last option is highlighted. A hand cursor is on the third option out of four.

Figure 4-50

Select the Desktop Flow option

A new popup will open; click the Download app. If you already downloaded it, click the Launch app. It will download an .EXE file. Double-click the setup file and install it in your desktop. After installation, click the Launch app from the popup. Figure 4-51 shows the launch Desktop Flow app option.

A dialog box of Build a desktop flow. On the left is an illustrated robotic arm with a file above a box while attached to a laptop. The upper right has a text, Create desktop flows for no additional cost preview title. The download app button is highlighted as step 1, while the Launch app button on its side is highlighted as step 2.

Figure 4-51

Launch Desktop Flow app option

The Launch app will open the Power Automate Desktop app. From the desktop app, click login and choose the correct environment. Click + New Flow. Figure 4-52 shows the Desktop Flow home screen.

A window of Power Automate Desktop preview. The name Sanjay Prakash is on the upper right. The options to add New flow, Go Premium, Settings, Help, and Search Flows are located at the top. My flows text is on the upper left. An illustrated laptop with a cursor is on the center of the page, just above the highlighted New flow button.

Figure 4-52

Desktop Flow home screen

Provide a name for the flow and click Create. Figure 4-53 shows the create a new Desktop Flow process.

A dialog box of Build a flow. On the left is an illustrated robotic arm with a file above a box while attached to a laptop. On the upper right is the Take back up folder and files entry in the highlighted Flow name field. On the lower right is the highlighted Create button next to Cancel.

Figure 4-53

Creating a new Desktop Flow

This will open the Desktop Flow designer, where you can drag-and-drop actions to the main screen. The following example shows how to copy a folder with files from one location to another.

Use the Search Folder action and drag the Copy Folder step from the action pane to the main screen. Figure 4-54 shows the home screen of the Desktop Flow editor.

A window of Power Automate Desktop preview. Three sequenced steps are as follows. From the left panel titled Actions, type the text folder on the search bar and click the Copy folder under the Folder section. Drag it to the main page to complete the process. On the right are the Variables.

Figure 4-54

The home screen of the Desktop Flow editor

You now have to provide information about the folder you want to copy. Select the Folder to Copy, Destination Folder, and If Folder Exist options. If you want to override the folder, choose the Overwrite option and click Save. Figure 4-55 shows the Copy Folder action.

A dialog box of the Copy folder. Under Select parameters, Folder to copy is set to C colon backslash Users backslash Admin backslash Videos backslash Captures, the Destination folder is set to the same location but with OneDrive and Pictures, and If folder exists is set to Overwrite. Save and Cancel buttons are on the lower right where Save is selected.

Figure 4-55

The Copy Folder action

Now click the Run button to play the flow. After the flow run, you will see the folders copied from the source folder to the destination. Figure 4-56 shows the copy folder result.

Two File Explorer windows placed side by side. The Videos folder under This PC, the test dot t x t file on the main page, and This P C, Videos, and Captures on the address bar are highlighted. An arrow connects the address bar to that of the next window with Pictures and Captures. The file test dot t x t and Pictures folder are also highlighted.

Figure 4-56

The copy folder result

You can create a Desktop Flow for web and desktop automation using actions and running it as needed.

Dynamic Values and Expressions in Flows

Power Automate allows you to use dynamic values and write expressions for more complex data operations. To any field value, you can assign a static field or use the Dynamic panel to choose dynamic data from the previous steps.

Figure 4-57 shows the process of adding dynamic values to a field.

A window of Send email V 2. The Email, Subject, and Message entries in the To, Subject, and Body fields above Attachments fields are highlighted. Three arrows, from the Dynamic content tab panel with User Email and Email entries under the search bar point to the highlighted entries.

Figure 4-57

Adding dynamic values

Using expressions, you can do string operations, date operations, and so on, in Power Automate. Let’s consider an example here. You want to send renewal due date email to a student using an instant flow.

Create an Instant Flow in Power Automate

Open flow.microsoft.com and log in using your credentials. Choose the correct environment. Choose the +Create option and then choose Instant Cloud Flow. In the Manual Trigger area, add a Text parameter for the email field. In the next step, add a new action to send an email using the Gmail connector.

In the Email To, assign the Email parameter from the Dynamic content panel, which is part of the Manually Trigger a Button step. Specify the email subject as “Reminder – Student Renewal Pending” and, in the Email body, add “Dear Student, your renewal due date is”. After “is,” you’ll want to display the current date plus one year. So, for these types of scenarios, you need expressions.

Click the location where you want to add the expression and then click the Add Dynamic Content link, which will open the Dynamic panel.

Select the Expression tab from the Dynamic panel. You can type in expressions, as shown in Figure 4-58, which uses the addDays expression. The first parameter is the current date, so we used utcNow(). The second parameter is how many days you want to add to the current date. After these steps, click Update.

A Manually trigger a flow window connects to a Send email V 2 window through a downward arrow. The add Days ellipsis in parentheses in the Body is highlighted and is where the arrow points from the Update button of the Add dynamic content panel with add Days open parenthesis u t c Now open and close parentheses comma 365 entry under Expression field.

Figure 4-58

Adding an expression

When you run the flow, the expression is evaluated in real-time and updated in the email body.

There are hundreds of expressions available. You can refer to all such expressions using the Microsoft knowledge base at https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference.

Using Variables, Loops, and Conditions

You can use variables, loops, and conditions inside Power Automate as needed. Variables are a good way to store data temporarily in a placeholder.

Working with Variables and Conditions

Only use variables when required. For example, say you are sending multiple emails to a person in multiple steps and you do not want to specify the email of the same person in every email send action. You can store the email ID once in a variable and use the variable each time.

To achieve this, create a flow such as an Instant Cloud Flow. After the trigger, add a new step and search for Variable. Choose the Variable connector and select Initialize Variable Action. Figure 4-59 shows this process.

A window with the highlighted label Variable. Under the Actions tab of the search bar are the entries Append to array variable, Append to string variable, Decrement variable, Increment variable, Initialize variable, and Set variable. A hand cursor is on the highlighted Initialize variable entry.

Figure 4-59

Choosing a variable

Specify a name for the variable and set the Type to String. You can choose a variable type of Boolean, Integer, Float, String, Object, or Array. Figure 4-60 shows the process of choosing the variable data type.

A window of Initialize variable. The Name field has the entry email id. For Type, Boolean is highlighted from six available options namely, Boolean, Integer, Float, String, Object, and Array. The hand cursor is on the String entry.

Figure 4-60

Choose a variable data type

In the Value field, provide the email ID that you want to use in further steps. Figure 4-61 shows the process of assigning a value to a variable.

A window of Initialize variable. The Name field has the entry email id. For Type, the Type is set to String, and the Value field has the entry s p p maestro at sign g mail dot com.

Figure 4-61

Assigning a value to a variable

You can add new steps to perform your additional actions, such as if Today Day is Monday, send email body “You have to work on consulting”; otherwise, send email body “Work on Training”.

Use a Condition Connector step and, to the Condition value, add the dayOfWeek expression. Inside that expression, pass utcNow. This will return the day of the week as an integer. If the current day is Monday, it will return 1. Figure 4-62 shows the assign expressions to condition process.

A window is labeled as Condition. Its three fields have highlighted entries of day Of W ellipsis, is equal to, and 1. The Add button is on the lower left. From the Add dynamic content option, a panel opens and exhibits the highlighted day Of Wek open parenthesis u t c Now open parenthesis double close parentheses entry under the Expression tab.

Figure 4-62

Assigning expressions to conditions

In the Yes condition, add a Send Email step. In the To field, choose a variable from the Dynamic content panel. Choose a subject and body as per the scenario. Figure 4-63 shows the process of assigning dynamic content to a field.

A window of Send email V 2. The empty field for To is highlighted. On its lower right is the highlighted Add dynamic content option, which opens a panel on the right. From there, Dynamic content exhibits highlighted Variables section and its email i d entry, where a hand cursor is placed nearby. If Yes and If No windows are in the background.

Figure 4-63

Assigning dynamic content to a field

Now add another Send Email action inside the No section. If the condition is not met, the step will execute. Figure 4-64 shows this condition branch.

A window labeled Condition highlights day Of W ellipsis, is equal to, and 1 entries. Below, If yes tab has Send email V 2 window with highlighted email id, Its monday Assignment, and You have to work on consulting entries for To, Subject, and Body fields. If no tab has Send email V 2 2 with highlighted email i d, Usual Assignment, and Work on Training entries.

Figure 4-64

The condition branch

You used the same variable in both steps. If you test this, you will get an email based on the current day of the week.

Working with Loops

You can use loops to read values from a list of items using iteration. For example, you can use loops to read all rows from an Excel sheet, you can use loops to insert data into the Dataverse from an Excel sheet, and so on.

Say you want to send an email to all the students of your schools stored in the Dataverse. For this scenario, you have to use a loop that will run every student record and send the emails.

Create an Instant flow and add two input parameters—Subject and Body—using the Text type. Add a new step and search the Dataverse. Choose the Students table and the List Row action to read all the students. Figure 4-65 shows the List Row action for the Dataverse.

A window of List rows. The Table name is set to Students. The Show advanced options button is on the lower left.

Figure 4-65

List Row action for the Dataverse

Now add a new step and choose Control ➤ Apply to Each. Figure 4-66 shows the process of assigning a value list to a loop.

A window of Apply to each. Select an output from previous steps is highlighted along with its value entry. The Add dynamic content on the lower right opens a panel with the value entry under the List rows of Dynamic content tab which is highlighted and has a hand cursor. A connection with Send email V 2 window through a downward arrow is observed.

Figure 4-66

Assigning a value list to a loop

Inside the loop, add a Send Email action and assign the email from the List Row step to the To value. Figure 4-67 shows this process.

A window of Apply to each. Select an output from previous steps is highlighted along with its value entry in its field. The Send email V 2 window is superimposed and has highlighted Email, Subject, and Message entries for To, Subject, and Body. The Add dynamic content panel highlights the Email entry under the List of rows of Dynamic content tab.

Figure 4-67

Assigning an email field value using dynamic content

This is how you use loops in Power Automate.

Working with Approvals in Power Automate

Approvals are important scenarios in every business. Say you want to send an approval to one or more people to approve an amount of student joining fees when the amount is less than $200.

To achieve this business scenario, previously you had to write lots of code. Now you can achieve this with no-code. Use the following steps to do this.

Make sure you have an Office 365 Outlook license for your employees to use approvals.

Step 1: Add an Automated Cloud Flow

In your Power Apps solution, add an automated cloud flow named Send Approval for Student Payment Less Than 200 USD. Choose Connector for the Dataverse and the When A New Row Added trigger. Set the Scope to Organization. Set the Table name to Student Payments. Figure 4-68 shows the Dataverse trigger after a new row has been added.

A window labeled, When a row is added, modified, or deleted is on a page with the label Send Approval for Student Payment less than 200 U S D on the upper left. The window has Added as its Change type, Student Payments as its Table name, and Organization as its Scope. The Show advanced options button is on the lower left.

Figure 4-68

The Dataverse trigger when a new row has been added

Add a new step and search for a connector called Approval. Figure 4-69 shows the Approval connector.

A window of Choose an option. The search bar has a highlighted approval entry. Below is the opened All tab with a highlighted Approvals entry. A hand cursor is placed below its icon.

Figure 4-69

The Approval connector

From the list of actions, select Start and Wait for an Approval. You can choose Create an Approval or Wait for an Approval also, depending on your needs. The approval will raise and wait until the approver takes action so that the payment record will be updated. Figure 4-70 shows the Approval action type.

A window of Approvals. Under the Actions tab of the search bar are the entries Create an approval, Start and wait for an approval, and Wait for an approval. The Start and wait for an approval is highlighted. The hand cursor is placed nearby.

Figure 4-70

Approval action type

It will automatically create a connection for the Approval connector. Set the Approval Type to Approve/Reject – First to Respond. Figure 4-71 shows the approval types.

A window of Start and wait for an approval. The entries under Approval type are Approve or Reject Everyone must approve, Approve or Reject First to respond, Custom Responses Wait for all responses, and Custom Responses Wait for one response. The Enter custom value entry is added below.

Figure 4-71

Approval types

Approval Types

  • Approve/Reject – Everyone must approve: Select this when you want all approvers to have to approve this action.

  • Approve/Reject – First to respond: Select this when you want your approval to be completed by the first approver to take action.

  • Custom Response – Wait for all responses: Select this when you want your approval to be completed by all approvers with a custom action.

  • Custom Response – Wait for one response: Select this when you want your approval to be completed by at least one approver with a custom action.

Once you have chosen the approval type, specify other information, such as a title, who it’s assigned to, any details, an item link, and a description. Figure 4-72 shows the process of assigning values during the approval stage.

A window of Start and wait for an approval. Approval type is set to Approve or Reject First to Respond, Title is set to Approval Required Student Payment less than 200 U S D, Assigned to Sanjay Prakash, Details is set to Please take action, and Item link is set to Student and Student Value. The Item link description field is empty.

Figure 4-72

Assigning values during the approval stage

Step 2: Check the Approval Status

Add a new step to check if the approver has taken action—either approved or rejected the approval. In the Condition value, choose the Responses Approver response. It will create a loop automatically, as the Responses field contains multiple responses from approvers. Figure 4-73 shows the Read Approval response.

A window of Apply to each. The Responses entry of Select an output from previous steps above Condition title bar is highlighted. On the lower right is Add dynamic content option with an opened panel. Here, under the Dynamic content, entries such as Responses Approver response is highlighted and the hand cursor is placed on it.

Figure 4-73

Read Approval response

Expand the Condition Inside loop and, in the Condition value, specify Approve. If the Response is Approve, then send an email as approved. Otherwise, the email will be rejected. Figure 4-74 shows the conditional approval branch.

A window of Apply to each with a Responses x entry. Condition window in the mid-top part has highlighted Responses, is equal to, and Approve entries. Below, If yes and If no tabs have highlighted To, Subject, and Body field entries under Send email V 2 and Send email V 2 2. The difference lies in the approved and rejected statuses in the Subject field.

Figure 4-74

The conditional approval branch

Now save the flow and create a student payment record with less than $200. The flow will trigger. Figure 4-75 shows the student payment form.

A zoomed section of a webpage with the text payment for Rahul on the upper left. Below, the General tab is opened. Name is set to payment for Rahul, Student is set to Rahul Sharma, Terms is set to 1, Due Date is set to November 4, 2022, Total Amount is set to highlighted 188 dollars, and Owner is set to Sanjay Prakash.

Figure 4-75

The student payment form

Check the flow status in the Flow Details page. It’s showing in running status. Figure 4-76 shows the flow status.

A zoomed section of the Flow Details page. The Send Approval for Student Payment less than 200 U S D location on the upper left, following Development and Cloud flows, is highlighted. Below, Details and 28-day run history sections are observed. The Running entry under the Status column of the latter section is highlighted.

Figure 4-76

The flow status

If you click the item, it will display in run mode and that you can check where it is waiting. Figure 4-77 shows the flow status in progress.

Three title bars with the labels When a row is added, modified, or deleted, Start and wait for an approval, and Apply to each connected through downward arrows. Apply to each is greyed out. When a row is added, modified, or deleted has a checked 0 second marker on the right, while Start and wait for an approval has a running 2 minute timer.

Figure 4-77

The flow status in progress

Now it’s waiting for the approver’s response. The approver will open their Outlook to see the approval email. Figure 4-78 shows the approval email received.

A section of the Outlook webpage. On the left panel, the Microsoft Flow entry under the Focused tab is highlighted. On the main page, the Approval Required Student Payment less than 200 U S D text is highlighted. The same highlighted text appears in the middle of the page. The Approve and Reject buttons at the bottom are highlighted where Approve is selected.

Figure 4-78

The approval email was received

If the approver clicks Approve, it will resume the flow. It will open a confirmation page, where the approver can click Confirm. Figure 4-79 shows the approval taking action.

A zoomed confirmation page. The title reads Respond Approve. Under the Overview section, Approval, Requester, Received, and Link have the necessary information. Under the Details section, the Please take action text appears. Choose your response is set to Approve. Add a comment field has the text ok. Confirm and Cancel buttons are on the lower left.

Figure 4-79

Taking action

Now the flow will resume and complete. The approval email will be sent.

Business Scenarios, Use Cases, andImplementations

You can work on the following business scenarios for practice.

1

The system must provide a process to streamline the student on-boarding process and capture general information, communication information, and course information.

Configure Business Process Flow using Power Automate.

2

As soon as a student is created, the system should send a welcome email to the student and create a task to collect payment from the student after three days.

Use Automated Cloud Flow using Power Automate.

3

Automatically send a timesheet fillup email and link the Power Portal to students to fill in the timesheet daily.

Use Scheduled Flow in Power Automate.

4

Fetch the latest currency exchange rates from a third-party WEB API currency layer and display them on a Canvas app.

Use Power Apps Trigger Flow.

5

Whenever a lead is created in the Dataverse with more than $50,000 annual revenue, send approval for the manager and wait for approval. After approval, update the lead for qualification process.

Approvals in Power Automate

Summary

In this chapter, you learned about the following concepts:
  • Power Automate building blocks

  • Connectors in Power Automate

  • Types and uses of flows

  • Dynamic values and expressions in flows

  • Using Variables, loops, and conditions

  • Working with approvals in Power Automate

  • Business scenarios, use cases, and implementations

In the next chapter, you will learn about the following:
  • Concept of Power Virtual Agent

  • Building blocks of Power Virtual Agents

  • Configuring a sample Power Virtual Agent

  • Deploying a Power Virtual Agent in public websites/portals

  • Business scenarios, use cases, and implementations

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.67.177