Determine If Records Were Returned From A List Rows Step in Power Automate

By - March 23, 2022

Querying for the existence of records is a common requirement. If you are familiar with the ‘list rows’ step, you know that if you are using this action, the ‘Apply to Each’ functionality can cause a huge headache if you are not actually attempting to loop an action.

A use case for this is querying for existing contacts with a certain email address. In my flow, I would do a list rows step to retrieve contacts with that email address and if something returns, I would want to continue to do another action. I am really only interested in the number of records returned, not the actual returned records.

List Rows step to get records and then Condition using length expression

Let’s take a close look at that expression in the condition:

length expression to get length of list rows

We are using the length() function and passing the context of the list of values from the ‘List Rows’ step. This will provide us with the number of rows returned from the ‘List Rows’ step. If the expression is greater than 0, we know there is at least one existing contact with that email address, and we will continue to the If yes branch.

You can create this expression by typing in length() into the expression box. Inside the parentheses, navigate back to the Dynamic Content tab and select the ‘value’ item from your ‘List Rows’ step.

Your expression should be: length(outputs('{name of step}')?['body/value'])

Receive Posts by Email

Subscribe and receive notifications of new posts by email.