cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User III
Super User III

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

View solution in original post

Frequent Visitor

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.

View solution in original post

Highlighted
Super User III
Super User III

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

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

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

View solution in original post

Frequent Visitor

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.

View solution in original post

Highlighted
Advocate I
Advocate I

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

Highlighted
Super User III
Super User III

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

View solution in original post

Highlighted
Advocate I
Advocate I

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

Thanks @ScottShearer

 

This worked perfectly 🙂

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (8,820)