cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

SharePoint List Get Items what to do when Values equal Null

I have a flow that runs once a week using a Recurrence. The Get Items connector for SharePoint filters the list based on the next weeks upcoming events. An email then is sent listing the upcoming events.

This has been working fine but now I would like to add a Condition so that when the Get Items Filter return Value: [] meaning no events for that week a different email is sent rather than my Flow just failing.

I can't figure out how to do this. I have tried a Condition where the value (List of Values) equals [ ], NULL, Blank, 0.

3 ACCEPTED SOLUTIONS

Accepted Solutions
Super User III
Super User III

@DudelerDad:

 

You can use the length() expression to check for no items being returned by get items.  You'll find length() under the Collections heading.

 

In the example below, the variable will be set to zero if there are no items returned:

ArrayLen.jpg

 

So, have a condition that checks for zero.

 

If this answers your question, please mark your post as Solved.

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Thanks Scott that worked great and was easy to implement. I'm fairly new to Flow and the 'iniatilize variable' will come in handy.

View solution in original post

@Wheatcroft 

You can initialize the variable near the top of your Flow and before the loop - do not set it to a value.  Within the loop, use a Set Variable action and use the expression that I showed above to get the number of items.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

5 REPLIES 5
Super User III
Super User III

@DudelerDad:

 

You can use the length() expression to check for no items being returned by get items.  You'll find length() under the Collections heading.

 

In the example below, the variable will be set to zero if there are no items returned:

ArrayLen.jpg

 

So, have a condition that checks for zero.

 

If this answers your question, please mark your post as Solved.

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Thanks Scott that worked great and was easy to implement. I'm fairly new to Flow and the 'iniatilize variable' will come in handy.

View solution in original post

@ScottShearer 

 

Hi Scott, 

 

I have tried to use this solution in a flow I am building to create/update items in a SharePoint list.

 

The 'Get items' action is within a 'For each' container, and when I try to add the 'Initialise variables' action I get an error;

 

'The operation 'Initialise variable' can only be used at top level'.

 

Are there any other methods to achieving this?

 

Many thanks,

 

Lucy

@Wheatcroft 

You can initialize the variable near the top of your Flow and before the loop - do not set it to a value.  Within the loop, use a Set Variable action and use the expression that I showed above to get the number of items.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Thanks @ScottShearer

 

This worked perfectly 🙂

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (80,304)