Get People picker properties on client side

Some times you need to get user name from people picker for sending mails, comparing to other fields , displaying some where. Below is the few tricks that are useful to get name, and other user properties from picker.

Below is the simplest way to get user name from picker.
$('div[title=PeoplePickerDivTitle] span span span').text()

And the below is the use full to get people picker properties email, user id ..etc

var userdetails = JSON.parse($('input[ID^=PeoplePickerDivStartID][ID$=HiddenInput]').val())
if(userdetails[0]){
      var displayname = userdetails[0].DisplayText
Var email = userdetails[0].EntityData['Email']
}

above script parse the people picker hidden input data which contains user values into JSON, and will get all user properties that exists in people picker control.

Comments

Popular posts from this blog

PAGE NOT FOUND ERROR PAGE IN SHAREPOINT 2013

Send Mails in SharePoint Event Receiver

Get Host site list items in SharePoint Hosted App.