cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
misc
Helper V
Helper V

Display plain text email addresses from selections in people picker

My app allows a manager to assign a ticket to multiple staff members using a people picker, however, we want to be able to store the assigned staff member's email addresses in a plain text string in order for it to work well with a couple of flows we run later down the line. 

 

I had tried to create a collection OnChange and then concat the email columns of the collection but have been having trouble with removing items from the collection if they are removed from the people picker, or if a second staff member is assigned in a different session than the first, then the first appeared to drop off the collection too. 

 

I also had a problem that I had set a 'DefaultSelectedItems' to the assigned user in certain situations eg. a certain task is selected therefore it is automatically assigned to the expert in that field, but the defaultselecteditems property didn't seem to trigger the OnChange meaning the email address was not added to the collection/string.

 

Is there any way to collect the email addresses from the people picker both on a manual change and a default selection?

 

At the moment I have changed the dropdown to a basic combobox where the manager just picks out email addresses from the list, but I find it much more aesthetic and user friendly to choose/display names rather than emails!

 

Any help is appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
zmansuri
Super User
Super User

6 REPLIES 6
CNT
Super User
Super User

@misc For the purpose of easily adding and removing from the Collection, it would be better to store the emails as separate records without concatenating them. You can always concatenate them before sending it to a Flow.

OnChange  will get triggered only when a change is manually made (In some strange occasions it does get triggered when the Default value changes but it is not designed to work like that. So, don't rely on that).

To add the email based on some other change you can add it to the collection in the same place where the other change is made.  

zmansuri
Super User
Super User

Thanks for your response. I have gone back and tried to do this today but my collection does not seem to be getting the email address at all now?

 

Code of taskdpd is:

ClearCollect(Assigned, {Name: DataCardValue10.SelectedItems.DisplayName, EmailAddress: DataCardValue10.SelectedItems.Email})

 DataCardValue10 is the peoplepicker which has the default:

datacardvalue10.png

 

And my collection ends up looking like this:

assigned.png

 

The DataCard TicketAssignedToName I have tried both:

 

Concat(Assigned.EmailAddress, "; ")

and as you suggested:

Concat(DataCardValue10.SelectedItems, Email, "; ")

The former ends up just showing the semi-colon and the latter returns empty. It just seems Email isn't collecting at all?

 

Not sure what I'm doing wrong here! 

Your ClearCollect function assigns

Name: DisplayName
EmailAddress: Email

but the initial list in the taskdpd only has those fields: @Data.type, Claims, DisplayName

 

Naturally, in the collection you have values for DisplayName, but not the e-mails, since there's no Email field, or?..

I'm not sure actually...though I had it working previously and I was sure I used Email then so I had assumed that wasn't the problem.

 

I managed to use this code in the plaintext label in the end and it is working fine. I think this is what Zmansuri had meant in the first place but I hadn't understood properly.

Concat(DataCardValue10.SelectedItems, Email, "; ") & Label11.Text

 

Glad we managed to lead you to the solution together with @zmansuri 🙂

Have a good day

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,104)