cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Condition based on SharePoint 'Get Items' action returning no data

I'm building a Flow for faculty to submit course requests. Each of them has an "approver" which may or may not be their actual "manager" in Azure AD, so we have a separate list in SharePoint that matches Faculty > Approvers. In Flow, I'm using a SharePoint > Get Items action with an Odata filter of [FacultyEmail] eq <email of the faculty who started the Flow>. Now, the FacultyEmail column in the list is required to be unique, so there cannot be more than one result (that is, this action will always return a single-row array), but there may be zero results (ie: a faculty member is hired, but not added to the Faculty Approvers list).

 

Basically, what I want/need to happen is: If there is a result, append the Approver's email to a variable (var_FacultyApprover), if there is not, send them an email indicating that they do not have an Approver.

 

With the test user in the Faculty Approvers list, this works great. However, I can't seem to get the syntax right for the "no results" scenario.

 

I've tried evaluating the body/value of the action to see if it's 'null', which didn't work. I kind of understand this because the results are an array or table, not a string, and I think null only works against strings. 

2019-08-07_15-39-17.png

 

What I think should work (but obviously isn't) is using the 'empty' expression to see if the result set is, well, empty.2019-08-07_15-55-47.png

The left side of that condition is set to empty(outputs('Get_Faculty_Approver')?['body/value']) (I also tried empty(outputs('Get_Faculty_Approver')?['body']) but got the same results). 

 

This doesn't cause the Flow to fail, but it doesn't do what it's supposed to do. That expression should return true if the set is empty (which it is), so if true = true, it should be sending an email, but it's not.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Condition based on SharePoint 'Get Items' action returning no data

@jwhite , thanks. I fiddled with it some more but could not find the right expression, so I changed my approach a bit. Basically, if it finds the user in the list, it populates a variable with their approver's email. If they aren't in the list, then that variable is empty, so I have a condition after the "set variable" action that checks whether it is empty or not. This seems to be working reliably. It's nice that Flow allows us toe tackles these kinds of problems from many different angles.

View solution in original post

2 REPLIES 2
Highlighted
Resolver III
Resolver III

Re: Condition based on SharePoint 'Get Items' action returning no data

Hi @ChadVKealey ,

You mostly have it right, but you can use the length expression to return the number of items in your filtered array.

I set up the flow below to filter a list by the input from manually triggering the flow then testing to see the length of the array returned with the expression:

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

No filter results flow.pngNo filter results expression.png

You could also set the condition to have the length set to equal a certain number or reach a certain threshold if you needed more specific control of a number of items in a list.

Hope this helps!

 

 

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Condition based on SharePoint 'Get Items' action returning no data

@jwhite , thanks. I fiddled with it some more but could not find the right expression, so I changed my approach a bit. Basically, if it finds the user in the list, it populates a variable with their approver's email. If they aren't in the list, then that variable is empty, so I have a condition after the "set variable" action that checks whether it is empty or not. This seems to be working reliably. It's nice that Flow allows us toe tackles these kinds of problems from many different angles.

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new 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!

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