1

Need to grab user email from SharePoint people picker and show an alert. I have tried below options but unable to get an alert after adding the name in people picker.

var supervisorPicker = SPClientPeoplePicker.SPClientPeoplePickerDict['Reportee_x0020_Of_f56eef23-35a8-4afe-8ffe-3cbf6993a7ad_$ClientPeoplePicker']

supervisorPicker.OnValueChangedClientScript = function (peoplePickerId, selectedUsersInf)
{
     var supervisorEmail = supervisorPicker.GetAllUserInfo()[0].EntityData.Email
     showAlert(supervisorEmail);
};

and,

var sup = $().SPFindPeoplePicker({  
    peoplePickerDisplayName: "Reportee Of"  
});
if(sup != undefined){
    showAlert(sup.dictionaryEntries[0].Email);
}

my showAlert function is like this:

function showAlert(email){
    $.ajax({
         url: "http://xxxxxxx/DataService.svc/jsonData/"+email
    }).then(function(data) {
         alert(data.CL);
    });
}

Let me know what I am missing, and how can I grab a people picker change event to call a function and show the alert.

0

you can use below code to retrieve user email from custom people picker.

var user=[];
// Render and initialize the client-side People Picker.  
    function initializePeoplePicker(peoplePickerElementId) {  
        // Create a schema to store picker properties, and set the properties.  
        var schema = {};  
        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';  
        schema['SearchPrincipalSource'] = 15;  
        schema['ResolvePrincipalSource'] = 15;  
        schema['AllowMultipleValues'] = false;  
        schema['MaximumEntitySuggestions'] = 50;  
        schema['Width'] = '280px';  
        // Render and initialize the picker.  
        // Pass the ID of the DOM element that contains the picker, an array of initial   
        // PickerEntity objects to set the picker value, and a schema that defines  
        // picker properties.  
        SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);  
         SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnValueChangedClientScript=function (peoplePickerId, selectedUsersInfo) {
            if(selectedUsersInfo.length>0)
            {
            user={selectedUsersInfo};
            //getInputUser(selectedUsersInfo);


            }
         };
    }

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.