Retrieve email from People or Group Field
-
15-01-2021 - |
Question
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
Solution
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);
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange