Text values from People Picker

Hi,

I've been looking at the instructions on this page:

https://plumsail.com/docs/forms-sp/javascript/fields-sp.html#people-picker

When I'm using

//returns an array of objects
fd.field('Persons').value;

I don't get an array returned to me, I just get the text of the selected option's 'value'.

Has something changed or am I not understanding this correctly. Previously I'd get an array in the console from which I could select the associated DisplayText, but this doesn't appear to be working anymore.

Hello @abolam,

If the field 'Persons' not allows multiple selections when you use fd.field('Persons').value; you will get the array of available properties.
image

And to get the display name of the user use fd.field('Persons').value.DisplayText;

If the field 'Persons' allows multiple selections when you will get the array of the selected users.

And to get the display name of the first selcted user, use fd.field('Persons').value[0].DisplayText;

Hi,

I'm not getting that array returned to me. The people picker does not allow multiple selections.

When I use fd.field('Persons').value.DisplayText I get undefined in the console

If I try fd.field('Persons').value[0].DisplayText I get undefined

If I try fd.field('Persons').value I get the users UPN i.e. their login name returned as a string

In none of the above scenarios am I able to access the array.

This is in a client's site, so I will see what I get in our development tenant and check it against this. If the results are different, is it possible my client is doing something to prevent the access of the people picker? Seems unlikely but I will investigate.

@abolam,

Could you please do the following so we could troubleshoot the issue.

  1. Define fd globally in JavaScript Editor with this line:

window.fd = fd;

image

  1. Execute the following code in the console (F12) and share the screenshot of the result.

fd.field('Persons').value;

Thank you!

Sorry previous reply had our clients production site details - screen is here, you can see it only shows the UPN in text, no array.

@abolam,

How is the field value set? Is it set manually or with the script?

User information loaded only if the field changed manually, and if it is not, you need to use PNP request.

Please find an example in this post:

Ah I see, I will review whatever code is setting the field and adjust if it isn't using PnP.

Makes sense if my we used some other way (probably the context JS object by first guess).

Will review and report back.

1 Like

Hi, that code in Tony's post is helpful, however when I want to set a people picker field programmatically, what value do I use, the ID or the UPN?

@abolam,

You can set the People Picker field value with the user's UPN, Email, Login Name.