cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DudelerDad
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
ScottShearer
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
ScottShearer
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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,455)