0

Shared with Image

I want to display user email address instead of user name when any user is selected from people picker using JQuery.

In People Picker control when any name is entered I want to display user's "Email" instead of user's "Display Name"

2

Check this answer i gave for how to implement PeoplePicker using JSOM for sharepoint 2013.

PeoplePicker using JSOM

You can add following function in above solution and call this function.

function GetUserInfo(){
        var pplPicker = SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerspanId_TopSpan;
        var userInfo = pplPicker.GetAllUserInfo();  
    }

Here "userInfo" variable will contain details of all the user that is selected in PeoplePicker field.

0

Check this other answer I gave someone else. It didn't solve their specific issue but it definitely worked for me.

https://sharepoint.stackexchange.com/a/154085/33297

The snippet uses SP.ClientContext only because the OP for that question needed it for something else. You can definitely do without that. My snippet also doesn't even need jquery.

Something like this should work:

    var pickerDiv = document.getElementById("<ID of people picker element>");      
    var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[pickerDiv.id];
    var theUser = peoplePicker.GetAllUserInfo();
    var theUserId = theUser[0].EntityData.SPUserID;
    alert("SP User ID: " + theUserId);

If you inspect the peoplePicker array in your browser console you will see the other properties available. Email should be one of them.

  • Thanks for your reply but I dont want to use ClientContext, I only want simple JQuery – DRS Sep 3 '15 at 9:58
  • Sorry for the confusion. I've fixed the answer for you. It is essentially the same as Rohit's though. – Lance Sep 3 '15 at 16:31

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.