Populate a SharePoint 2013 PeoplePicker field using JavaScript/jQuery
Here is a quick and fairly simple way to programmatically populate a SharePoint 2013 People Picker field with a user based on their email address. This example assumes you have more than one People Picker field on the page. You will need:
- The display name of the People Picker Field
- The email address of the user you want to add to the People Picker Field
Add the following code to either a Script Editor Web Part (inside <script> tags) or on your page in the PlaceHolderAdditionalPageHead, also in <script> tags:
var dispTitle = "";
var pickerDiv = $("[id$='ClientPeoplePicker'][title='" + dispTitle + "']");
var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[pickerDiv[0].id];
var usrObj = { 'Key': 'email@address.com'};
peoplePicker.AddUnresolvedUser(usrObj,true);
In one case, I had to remove the “title” attribute filter from the pickerDiv var to get it to work, but it was the only People Picker on the page, so we were good.
Hope this helps!
2 thoughts on “Populate a SharePoint 2013 PeoplePicker field using JavaScript/jQuery”
Working fine for active users but unable to resolve the inactive users and showing error message “Multiple entries matched, please click to resolve.”
Hi Manveer, it’s possible there are duplicate entries in your User Info List. Go to your site’s UIL (typically https://sitecollection/sites/_layouts/15/people.aspx?MembershipGroupId=0) and look for a duplicate entry, then check the box next to it and remove it from the site collection. That should resolve the issue.
Comments are closed.