-1

I want to set value in clientPicker with button click event. When i clicked button he returned response with user Display name "John Atanasov" i what this name in clientPicker texbox. How to do this ?

This is my code(But not working):

 var replacmentName = $("#lastReplacement").text();
 $("#peoplePickerDiv").find("div[role='TextBox']").text(replacmentName);
2

If you want to set the value in client people picker, You will need below things.

--Client Side People Picker Id --Account Id or Email of User/group which you want to set in client side people picker

Below is the code for set value in client side people picker

var divPeople = SPClientPeoplePicker.SPClientPeoplePickerDict.PeoplePickerDiv_TopSpan; PeoplePickerDiv_TopSpan - Specify the unique ID of the DOM element where the picker will render.

var userObj = { 'Key': "sample@sample.com" };

divPeople.AddUnresolvedUser(userObj, true);

0

I am not very clear with your question, but I guess you have another input or label with id='lastReplacement' from which you want to copy the text to your people picker on button click. If this is the case, use the title property of the people picker and insert your text.

var replacmentName = $("#lastReplacement").text(); $("[title='title of the people picker']").text(replacmentName);

To check if it is working, manually enter text into your people picker and run this code on your developer options console: $("[title='title of the people picker']").text().trim().split('<span')[0] =="" It will return true if there is no text and false if there is text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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