2

I am trying to add user keys based on the ID of the people

var actionowner = this.SPClientPeoplePicker.SPClientPeoplePickerDict.owner_TopSpan;
actionowner.AddUserKeys('909');

This works when I just pass the Title of People and groups, but I want to pass their ID as there are multiple matches when I pass the Title

For Example, the below code works, but in some cases like having two groups all users & all it will throw an error saying that there are more than one match

var actionowner = this.SPClientPeoplePicker.SPClientPeoplePickerDict.owner_TopSpan;
    actionowner.AddUserKeys('Vignesh S');

1 Answer 1

1

unfortunatelly you can't load a people picker by using the id of the user using the AddUserKeys method.

One suggestion: get the user name/title/display name by using the rest call /_api/web/siteusers/getById("id") or EnsureUser and then after retrieving the username you can set it to the people picker field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.