How to get data from people picker with JavaScript?

How to get data from people picker with JavaScript?

If the form you are working in has a people picker then you are all set. Today I am going to show you all about getting user data from People Picker with JavaScript. The data you will be getting back from this call isn’t a full SPUser object or anything that detailed.

How to get user ID from people picker?

According to your requirement, you can not get the id from the ClientPeoplePicker Control, the walk around is quite simple, with the key data mentioned by @Akshay Randive, you can call the next function: To call the method you use:

How to get the picker ID for SharePoint?

You need to get the picker id for SharePoint Client People Picker change event. I have got the same using OnUserResolvedClientScript as below.

How to get the ID of someone in JavaScript?

If you set it into Static then the ClientID value will be set to the value of the ID property: Now use the ClientID in your JavaScript code to get the ID (PeopleEditorID) (other answer) server-side code will only be of help if you can change the New/Edit-Forms and add .Net code

Where to find login ID in people picker?

This information is contained within the SPClientPeoplePickerEntity object that is returned in the process. Many fields are reused in the object. For example, the login ID is stored in the Description field, but it is also in the Key field. My suggestion is use the EntityData property as it contains all the fields above within it.

How to set the people picker field in SharePoint 2013?

Since you are using SharePoint 2013 I would recommend you to consider the following approach. In SharePoint 2013 for rendering of List Views and Forms was introduced a Client Rendering Mode (CSR). Add Script Editor webpart right below the list view web part.

How to add people picker field in SharePoint?

Edit the SharePoint list form. Or you can use script editor Web Part to include this code. In this code on button click, we are binding current logged in user to Employee field. The below example will explain how to get the Person details from the People Picker Field using JavaScript in SharePoint.

How to display error message in people picker field?

Using this code we can display the error message below the people picker field as SharePoint out of box will work. Edit the SharePoint list form. This is the commonly used functionality for most of the developer, hope this will help.