Describe expressions – Demonstrate the capabilities of Power Automate

Describe expressions

Power Automate provides a large collection of connectors with a wide selection of triggers and actions. Most of the triggers and actions have settings that the developer must configure before the flow will operate. Placing the mouse cursor in a text box causes a Dynamic content pop-up to appear.

This dialog box contains fields from the data source accessible by the connector. Selecting a field inserts a variable into the text box that is replaced by actual data when the flow executes. For example, selecting the Timestamp field inserts the Timestamp variable into the text box, as shown in Figure 5-22. When the flow runs, the variable will be replaced by the time stamp reflecting the date and time that the flow executed.

FIGURE 5-22 The Dynamic content pop-up dialog box with the Timestamp field selected

However, there are instances when developers might want to add operations that are not provided by an action’s native settings. For these cases, Power Automate supports the use of expressions, which can perform operations on existing values.

The previous example used the Get calendar view of events (V3) action and inserted the Timestamp variable into the Start Time text box. The action will therefore get the calendar events starting on the date and time the flow is executed. For the End Time value, the developer might want to get seven days’ worth of calendar information. The field could accept an exact date and time, in the correct time stamp format, but this does not provide a permanent solution for the flow.

Instead, the developer can insert the addDays() expression, which can calculate an end time seven days from the date and time that the flow is executed. Selecting the Expression tab on the pop-up menu displays a list of expressions that can perform a variety of operations. The addDays() expression, as shown in Figure 5-23, takes as its parameters the time stamp from which the days will be added and the number of days to add (or subtract, using a negative value).

FIGURE 5-23 The Expression tab in the pop-up dialog box, with the addDays() expression selected

For the purpose of this example, the value for the End Time field will be as follows:

addDays (utcNow(),7)

The utcNow() expression returns the time stamp for the current date and time, so the addDays() expression will take the date and time when the flow executes and add seven days to it. Other date and time expressions allow developers to add hours, minutes, or seconds to a given time.

Expressions can perform many other functions apart from working with time stamps. The expressions that Power Automate uses are taken from the Workflow Definition Language in Azure Logic Apps and are organized into the following categories:

■ String functions—Manipulate data strings by concatenating, replacing, splitting, trimming, formatting, and converting data

■ Collection functions—Work with data arrays by specifying their length, locating empty strings, joining elements, and locating their first or last elements

■ Logical functions—Perform calculations using if/then statements, arithmetical functions, and Boolean operators

■ Conversion functions—Convert input to different data types, such as integers, strings, Booleans, and XML or JSON values

■ Math functions—Perform standard arithmetical functions, generate random values, and identify minimum and maximum values

■ Date and time—Generate strings containing time stamps based on calendar functions, such as adding and subtracting time intervals and identifying the start of a time interval

■ Referencing functions—Provide the ability to work with the inputs and outputs of other triggers and actions

■ Workflow functions—Provide the ability to retrieve details about a flow and the URL of a trigger or action

■ URI parsing functions—Retrieve specific information about URIs, including host names, queries, paths, ports, and schemes

■ Manipulation—Retrieve information about and modify JSON and XML objects

Need More Review? Expressions

For a schema reference guide to the Azure Logic Apps Workflow Definition Language that contains expressions usable in Power Automate, see https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language?

Leave a Reply

Your email address will not be published. Required fields are marked *