Probably I've found a bug.
In spRendered I call a function which reads user profile and writes persons manager to extra field. Quite normal and popular situation.
Some users has a problem with it because system displays different peron as their manager.
The situation happens when you have persons with similar logins and display names. For example "DOMAIN\Adam.Dhont" with display name "Adam Dhont (Warsaw)" and "DOMAIN\Adam.Dhont1" and display name "Adam Dhont (Berlin)".
fd.field('personUserManager').value = props[i].Value;
The code above will write DOMAIN\Adam.Dhont as login name but Adam Dhont (Berlin) in fd.field('personUserManager').widget.text().
Any ideas how to go around with it?
Let me clarify a few things.
Is the issue with the incorrect display name occurs only when Person field is populated programmatically? Or do you also see the incorrect name when entering the name manually?
After saving the form what is the value of the personUserManager field? Is it correct?
Manually selected user works fine.
The issue appears when Person field is populated programmatically (like in your documentation). It doesn't matter if I use login name or email address.
Saved field has wrong data.
In my opinion it works this way:
code sets a login/email (
fd.field('personUserManager').value = props[i].Value;) and form searches for display name. While searching display name (in code only login or email is provided') it looks for all site users who starts with or contain this login name. Result is an array and it takes last received Display Name. This all before save - we have good field value but wrong Display Name.
When form is being saved it takes Display Name (which is incorrect) and searches for site users and fills all other properties from wrong site user, even if login or email has already been provided for the field.
I couldn't reproduce the issue on my form.
Please try setting the Person or Group field value by user's key property using the code without pnp request:
fd.field('personUserManager').value = 'i:0#.w|dev\\m.nikitina'
To get user's key property, define fd globally by adding the below code to the first line in JS editor:
Then, choose the user manually in Person or group field and get the value of the field using the code in browser console:
Hi @mnikitina !
Of course I had tried few attempts before I asked for help
I got the same effect.
Since we can't reproduce the issue on our side, we need more information.
Developers are asking to do the following and share the screenshot of the result:
Define fd globally. Add the below code to the first line in JS editor:
Execute the following code in the browser console (replace User with the internal name of the field):
fd.field('User').$on('change', v => console.log(v));
Then select each user manually, expand the output in the console and make screenshots. You should see something like this:
Clik on three dots to show the property value.
Then assign users by email/key (each user) with code:
fd.field('User').value = '[email protected]';
And again, make a screenshot of the console output.