cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Capturing the value of a People Field to use in an email

Afternoon all

 

I'm going spare! I have a fields across a number of lists which are People Fields. I need to use the value in these fields in an email To field to send and in the Body to address the person. However...when I pick the field from Dynamic Content it throws in an Apply to each loop which throws out the Flow. I've tried using the Get User Profile action with no luck, tried to capture it in a Compose action but it throws in an Apply to each loop again. Now I'm trying to capture the People field as a variable but it's either throing it into a Loop or not finding the variable by the time I get to the email alert.

 

Any ideas, it's driving me mad!

 

An example of one of the Flows is below:

 

MyFlow.png 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi again

So, the 'Apply to each' in the screenshot you shared is design intent, you assign an ODATA filter in its 'Filter Query' input, right? Then I guess the annoying 'Apply to each' automatically added by Flow editor happens when you try to add any 'Person' column related data (email, name, etc).

Assuming you also assign a single Person in each 'Responsible for Completition' column item, I would not be worried for this second 'Apply to each'... your flow should work fine since:

-your first 'Apply to each' (design intent) should be executed 10 times, and

-your second 'Apply to each' (annoying) will be executed just once per first 'Apply to each' iteration, 10 times in total

 

However, if you want to get rid of it, everytime you need to use 'Responsible for Completition' column dynamic content I would recommend to wrap it inside first() or last() based expressions. Please note with this option your Flow design will be more clear from visual point of view, but in order to get the expression working, you will have to forget about the dynamic content menu and type them by yourself

 

first(item())?['yourPersonColumn']?['Email']

or

last(item())?['yourPersonColumn']?['Email']

 

A similar approach... the one described in this post:

https://powerusers.microsoft.com/t5/General-Power-Automate/how-to-extract-email-address-from-a-share...

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

9 REPLIES 9
Super User III
Super User III

Hi

You want to get the email stored in a Person column for a specific item, right?

THen if you have he item ID, use 'Get item' instead

If you do not have the item ID, but know a value from another column that is unique in your SP list and corresponds to your target item, use 'Get items' Filtering this unique value, the result will be an array with one single item inside; meaning the Apply to Each will be executed once.

 

Please also note if your person column is defined as multivalue, flow editor will add a second Apply to Each, nested inside the first one. If this is your case, this post can be useful

https://powerusers.microsoft.com/t5/Building-Flows/Person-column-not-available-in-Send-email-with-op...

 

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Hi @efialttes Thanks for the reply.

 

I put a Get Item action in but as you hinted at when I tried to use the values it retrieved it threw in another  Apply for each loop. I didn't quite follow the steps in the post you linked to. In this instance I'm trying to use the value from a field called 'Responsible for Completition' do I need to add a variable cation at the start? 

Hi again
Not sure I understand your flow requirements, sorry. So you do not need to send an email to each person defined in each item, but to each person defined in a single item.
And, you managed to replace 'Get items' and use 'Get item' instead, right?
Thanx!


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



I didn't replace Get Items I added an additional Get Item action before the email. So that's a mistake?

 

The Flow is a Scheduled Flow and I want it to send an email alert to the person named in the 'Responsible for Completition' People field after the Flow has filtered the items via a set of date criteria (that part is working more or less!)

Hi again
" I want it to send an email alert to the person named in the 'Responsible for Completition' People field after the Flow has filtered the items via a set of date criteria (that part is working more or less!)"
So lets assume after filterimg your SPList with your date criteria, we get 10 items. Let's also assume you have stored a single Person per item in its 'Responsible for Completition' column. You want to send 10 emails, one per Responsible, right?
Thanx!


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Correct

Hi again

So, the 'Apply to each' in the screenshot you shared is design intent, you assign an ODATA filter in its 'Filter Query' input, right? Then I guess the annoying 'Apply to each' automatically added by Flow editor happens when you try to add any 'Person' column related data (email, name, etc).

Assuming you also assign a single Person in each 'Responsible for Completition' column item, I would not be worried for this second 'Apply to each'... your flow should work fine since:

-your first 'Apply to each' (design intent) should be executed 10 times, and

-your second 'Apply to each' (annoying) will be executed just once per first 'Apply to each' iteration, 10 times in total

 

However, if you want to get rid of it, everytime you need to use 'Responsible for Completition' column dynamic content I would recommend to wrap it inside first() or last() based expressions. Please note with this option your Flow design will be more clear from visual point of view, but in order to get the expression working, you will have to forget about the dynamic content menu and type them by yourself

 

first(item())?['yourPersonColumn']?['Email']

or

last(item())?['yourPersonColumn']?['Email']

 

A similar approach... the one described in this post:

https://powerusers.microsoft.com/t5/General-Power-Automate/how-to-extract-email-address-from-a-share...

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

You beautiful man @efialttes ! I took a leap and trusted the 'Apply to Each' loop after the Get Item and it's solved the problem thank gawd! Been going round in circles! Thanks again! 

HURRAY!

IT WORKS!

 

Thanx for your contribution to keep this community great!

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (6,576)