Check if Get Items Action returns more than Zero Records using FLOW

In this blog, we will see how to check the number of items returned by the Get Items action in FLOW

Introduction 

 
You might have a FLOW that takes items from a SharePoint list, SQL table, or Excel file. You may also be further processing the fetched records with HTML or Excel. It's important to check if the returned records aren't empty or more than 0 before further processing. This post will show how to check for the empty output of Get Items action.
 
Steps:
 
Open your FLOW in edit mode >> After Get Items action >> Add Condition action

Wrong trial with failed output >> If you use a length function with the “List Of Items”, then it won't work. It will fail because it's not a collection or array object.

Correct condition values to be added >> On the left side, add an expression with length function and use a value property of Get Items action output. This will give us the number of rows returned, it could 0 or more than 0.

length(body('Get_items')?['value'])

 

You can add a compare clause of Is greater than, and on the right side mention 0. That way, when the number of rows returned are more than 0, then you can take further action as you desire.

 

Check the below FLOW success output request for both scenarios >> when the output of Get Items action returns 0 rows, or more.

 

That’s it for this blog, I hope it helps. Thanks for reading!