cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChadVKealey
Level 10

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
ChadVKealey
Level 10

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
jwhite
Level 8

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!

 

 

ChadVKealey
Level 10

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

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!

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: 59 members 3,508 guests
Please welcome our newest community members: