cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DudelerDad
Level: Powered On

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
Super User

Re: SharePoint List Get Items what to do when Values equal Null

@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
DudelerDad
Level: Powered On

Re: SharePoint List Get Items what to do when Values equal Null

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

Super User
Super User

Re: SharePoint List Get Items what to do when Values equal Null

@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
5 REPLIES 5
Super User
Super User

Re: SharePoint List Get Items what to do when Values equal Null

@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
DudelerDad
Level: Powered On

Re: SharePoint List Get Items what to do when Values equal Null

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

Wheatcroft
Level: Powered On

Re: SharePoint List Get Items what to do when Values equal Null

@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

Super User
Super User

Re: SharePoint List Get Items what to do when Values equal Null

@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
Wheatcroft
Level: Powered On

Re: SharePoint List Get Items what to do when Values equal Null

Thanks @ScottShearer

 

This worked perfectly Smiley Happy

Helpful resources

Announcements
firstImage

Microsoft Flow Online Conference

Join us for a FULL day of FREE Microsoft Flow Sessions from some of the best minds in the industry!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

thirdImage

New Flow Community Board!

Check out the new Microsoft Flow Community Blog Topic Suggestion board!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 40 members 4,391 guests
Please welcome our newest community members: