cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
azmcfarl
Helper I
Helper I

Apply to Each Skips Condition for people field in SharePoint

Hi all, 

Having a bit of trouble with my Flow. 

 

I've got a people field ('witness') in SharePoint that if empty, I want it to return "N/A" as text in my email. If the SP field is empty, the apply to each's condition is skipped and I just get a blank. If there are people in the field, I get people just fine (though I haven't figured out to to separate with commas without the last name not having a comma after it). 

I've tried append to string (returns a blank), I've tried append to array (returns empty brackets). I still can't figure it out. 

Flow:
Capture.PNG

 

Result if the people field is empty:

Capture.PNG

 

Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @azmcfarl 

 

So you don’t want to use the expression directly into the set variable, as this will delete every semi colon or comma at the end of the variable.

 

I believe you do need the apply to each. But for the inputs in the loop you want to put the dynamic content Value from SharePoint.

That way the loop will loop over Each Value, and Append the  AnyEmployee field if not empty from Each Value in SharePoint.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

9 REPLIES 9
Jcook
Super User III
Super User III

Hello @azmcfarl 

 

In your condition, use empty() expression on the left side with your dynamic content Any Employee inside the ( ).

 

empty() will return true if the value is empty. So on the right side put true

*NOTE: for the right side use the expression true*


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





@Jcook thank you so much, it worked!

 

I have one last question for you. If I have people in the 'any employee' field, is there a way to separate people with a comma or semi colon, without the last name having a comma or semi colon behind it in the output email? It bugs me visually, but if there's no way to do it, it's not that big of a deal. 

 

Capture.PNG

 

 

Hi @azmcfarl 

 

Outside your loop add a Compose action and use this expression:

substring(YourVariable),0,sub(length(YourVariable),1))

replace YourVariable with your dynamic content for your variable


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Hi @Jcook 

I'm still having a bit of trouble with this one. Flow keeps telling me the expression isn't valid. 

 

substring(variables('Witness')),0,sub(length(variables('Witness'),1))

 

Hi @azmcfarl 

 

Sorry I missed a parentheses:

 

substring(variables('Witness'),0,sub(length(variables('Witness')),1))

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Hi @Jcook 

 

It's always the parentheses 🙂 

I'm getting this error now

Capture.PNG

Hi @azmcfarl 

 

This error is saying the variable is empty. Can you confirm that the variable has something in it for that run


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





So if I hardcode in the 'Any employee displayname' dynamic content, into the Witness variable initialization, it creates an apply to each loop, and Flow says that's a no-no. So this is what I have without it hardcoded, and getting the error that the variable is empty. Is this correct?Capture.PNG

Hi @azmcfarl 

 

So you don’t want to use the expression directly into the set variable, as this will delete every semi colon or comma at the end of the variable.

 

I believe you do need the apply to each. But for the inputs in the loop you want to put the dynamic content Value from SharePoint.

That way the loop will loop over Each Value, and Append the  AnyEmployee field if not empty from Each Value in SharePoint.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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 Kudoed Authors
Users online (2,384)