0

I have People or Group Field

Normally I retrieve value of fields as:

var fieldUsuario = ctx.CurrentItem.Notificar_x0020_a

But now I dont want text value, I debbug it and it have email in span as:

<span class="ms-entity-resolved" id="Notificar_x0020_a_084ffd45-b361-458e-b55f-c824ba8995ec_$ClientPeoplePicker_i:0#.f|membership|email@mydomain.com_ProcessedUser0_UserDisplay" title="User, SubName" style="max-width: 331px;">User, SubName</span>

As you can see it have: email@mydomain.com I want to retrieve this value. How can I achieve it? Regards

0

You can use the following script to find Email Address of the People Picker Value. if we have field name "Manager" with People Picker type then:

var arrEmailID = [];
var fieldName = "Manager";
var _PeoplePicker = $("div[title='" + fieldName + "']");
var emailSpan = $(_PeoplePicker).find('.sp-peoplepicker-userSpan');
if(emailSpan.length > 0) {
        $(emailSpan).each(function (){
            var _sid = $(this).attr('sid');
            arrEmailID.push(_sid);
            alert(_sid.split("|")[2]);
        })
}
else {
       alert("null");
}
console.log(arrEmailID);

Reference: https://social.technet.microsoft.com/Forums/azure/en-US/5e244f77-106b-4d26-8d8e-a1b5514489ec/get-people-picker-valueemail-id-on-sharepoint-online-edit-form

  • Omg incredible, how about if field have more than one email, I mean multi select. How can I get two email values? is it possible? – David May 3 '18 at 6:04
  • Hi David, Check the updated code, this will work for multiple values too. – Gopal Zadafiya May 3 '18 at 6:16
  • it looking for bot correctly but how can I save it in variable and separate them by commas? for example field: var fieldUsuario = _sid;, and foreach email add to fieldUsuario with a comma for example user1@onmicrosoft.com,user2@onmicrosoft – David May 3 '18 at 6:35
  • David, please check the updated code. – Gopal Zadafiya May 3 '18 at 6: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.