Over the years I have noticed several Power Automate expressions that keep coming up during Flow creation. Below are several of them, and a description of what each does. Like the JavaScript 101 code, this article will be updated regularly as more expressions become noticeably useful.
———————————————-
Get the First Item in an Object Returned by Power Automate
———————————————-
This expression allows you to return just the first row of a Flow’s JSON after it has been returned in a retrieval step. Below would be useful if I did a Dataverse Connector for “List Rows” (which normally would return multiple records) but I knew the search criteria would limit the retrieved rows to one record. This will help avoid an “Apply to Each” loop connector.
first(body(‘Get_Accounts’)?[‘value’])?[‘aux_accountid’]
first(outputs(‘Get_Accounts’)?[‘body/value’])?[‘aux_accountid’]
———————————————-
Add to Time and Add Days
———————————————-
Remember that a date should be in UTC format before using these methods (see below).
addToTime(triggerOutputs()?[‘body/aux_date’],24,’Month’,’yyyy-MM-dd’)
addDays(triggerOutputs()?[‘body/aux_date’],547)
———————————————-
Format a Date
———————————————-
formatDateTime(outputs(‘Get_Accounts’)?[‘body/aux_date’],’MM-dd-YYYY’)
———————————————-
Check if an Output Has Records Using Length
———————————————-
The simplest way I have found to check if an output has records is by checking the Length for “NULL.”
length(outputs(‘{name of step}’)?[‘body/value’])