0

i have a small requirement where in, i have a column "Employee Name" as a people picker field, now i just want to retrieve the employee name value in a variable after the user has entered his name in it.

1

You can extract Display Name from people picker element by following statement.

var employeeName = SPClientPeoplePicker.SPClientPeoplePickerDict["EmployeeName_TopSpan"].GetAllUserInfo()[0].DisplayText

Please note: "EmployeeName" here in "EmployeeName_TopSpan" is the people picker div element id

and

assuming that people picker will have only entry therefore we have taken zeroth index result from GetAllUserInfo method.

  • Hi yayati , in regard to your answer, how do i find out the div element id, i have inspected the element and the id i get is "id1b_fb02312c-4006-49bf-be76-f3fc26f5f5bf_$ClientPeoplePicker". Also, how do i write this down, will this work in PreSaveAction function? – jayant khushalani Apr 16 at 11:41
  • do i need to reference SPservices file for this code too? – jayant khushalani Apr 16 at 11:47
  • No need to reference SPService file. Try replacing EmployeeName_TopSpan with id1b_fb02312c-4006-49bf-be76-f3fc26f5f5bf_$ClientPeoplePicker in the above script. – Yayati Apr 16 at 11:51
  • i did that too but it did not work – jayant khushalani Apr 16 at 11:51
  • Are you using default NewItem form or custom form? – Yayati Apr 16 at 11:52

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.