cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChadVKealey
Power Participant
Power Participant

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

@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
jwhite
Resolver III
Resolver III

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!

 

 

@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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (2,592)