cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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 @Anonymous 

 

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
MVP

Hello @Anonymous 

 

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





Anonymous
Not applicable

@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 @Anonymous 

 

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





Anonymous
Not applicable

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 @Anonymous 

 

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





Anonymous
Not applicable

Hi @Jcook 

 

It's always the parentheses 🙂 

I'm getting this error now

Capture.PNG

Hi @Anonymous 

 

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





Anonymous
Not applicable

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 @Anonymous 

 

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





Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,292)