cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rts2308
New Member

Using condition to determine empty array or body for Get items

Hello,

 

Hoping someone can help, please.

 

I have a flow which does the following:

1. List rows present in a table (from excel file)

2. Apply to each row it Get Items from a sharepoint list. I have a filter query in the get items so that data from Customer ID in sharepoint list matches the Customer ID from excel table 

 

Step 1 and 2 work fine my problem is after that. I am having trouble with using the condition to determine if the output from the get item is empty or there is a value. If the output is empty then I want to create a new item and if returns a value then I want to update the existing item on sharepoint list - I know how to do these things, I am stuck with getting the flow to see if the output from Get items is empty or not. 

 

I have tried the expressions seen in previous posts and nothing seems to be working for me. I have tried the below:

 

empty('Get_items') is equal to True

length(body('Get_items')) is greater than 1

length(string(body('Get_items'))) is less than or equal to 2

 

When I run through the tests the condition is only initiated and therefore returns an expression when there is a value. When there is no value the condition is not even initiated and no true or false expression is returned.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Using condition to determine empty array or body for Get items

Hi @rts2308 

 

Thanks for your quick reply. You need to check immediately after the list rows. Then add an IF condition to check if it's greater than zero or not. Then add the loop to iterate it. Please see below.

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

8 REPLIES 8
Super User
Super User

Re: Using condition to determine empty array or body for Get items

Hi  @rts2308 

 

Try this

 

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

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
rts2308
New Member

Re: Using condition to determine empty array or body for Get items

Thanks @abm 

 

Unfortunately, that did not work. Similar to all my other attempts when there was a value from the output of get items the condition was initiated to return a true or false expression. But when there no value (i.e. empty) the condition was not initiated. When you look through the test run results when the output is empty under the condition it says "not specified"

 

But appreciate you taking the time to answer - thanks again!

 

Super User
Super User

Re: Using condition to determine empty array or body for Get items

Hi @rts2308 

 

Please see below.

 

image.png

 

 

Run result:

 

image.png

Not sure why it's not working for you.

 

Is that going in your loop to iterate the blank values?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
rts2308
New Member

Re: Using condition to determine empty array or body for Get items

 I am not too sure why it isn't working either. 

 

So below is my overall flow

overall flow.png

 

Then I ran the test with the amended formula you suggested and if no value is returned from get items the condition is not initiated - screen show below:

value empty from get items.png

Compared with when there are values returned from get items

value not empty from get items.png

 

So I know the condition is working but can't get it too work when the output from 'Get Items' is empty.

Super User
Super User

Re: Using condition to determine empty array or body for Get items

Hi @rts2308 

 

Thanks for your quick reply. You need to check immediately after the list rows. Then add an IF condition to check if it's greater than zero or not. Then add the loop to iterate it. Please see below.

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

Highlighted
rts2308
New Member

Re: Using condition to determine empty array or body for Get items

@abm 

Thank you so much for that - got it working!

Been trying for a week - I would have never guessed that method!

 

Thanks again!

Community Support
Community Support

Re: Using condition to determine empty array or body for Get items

Hi @rts2308 ,

 

Please refer to screenshot below to create the flow:

1.png

The expression in the Condition as below:

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

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sk2912 Helper II
Helper II

Re: Using condition to determine empty array or body for Get items

Hello @abm  ,

 

I have kind of simliar problem also i am new to MS Flows.

 

I have 2 lists:

- List 1 (Offers made : name, address, etc.)

- List 2 (Offers accepeted or not)

 

Each order has a paticular Offer number (not item ID of sharepoint) .

 

What i want is when a new item is created in List 2 and Offer number in list 2 (only the newly created Offer number not all) is equal to Offer number in list 1 (offer ID) then call data from List 1 (eg. name, adress, etc.) with same Offer number and send an email with all the details in List 1.

If possible please reply fast.

Thanks in advance,

Sanket

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (6,760)