Is there a way to trigger a JS function when a People picker completes and finds a user? I'm developing a SharePoint 2013 app using client side development pattern.
Thanks for your suggestion Per, I have tried adding the OnUserResolvedClientScript into the control as follows but its not working, not sure if I can add it in this way?
// First we need to get the selected user from the person selected in the people picker
$(document).ready(function () {
// Specify the unique ID of the DOM element where the
// picker will render.
initializePeoplePicker('employeePickerSpan');});
// 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'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['OnUserResolvedClientScript'] = 'MyPickerUserResolved';
schema['Width'] = '250px';
// 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.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
}
function MyPickerUserResolved(topElementId, MyPickerUserResolvedusers) {
// users is set to GetAllUserInfo()
// Get the people picker object from the page.
var employeePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.employeePickerSpan_TopSpan;
// Get information about all employees.
var employees = employeePicker.GetAllUserInfo();
var employeeInfo = '';
for (var i = 0; i < employees.length; i++) {
var employee = employees[i];
for (var employeeProperty in employee) {
employeeInfo += employeeProperty + ': ' + employee[employeeProperty] + '<br>';
}
}
$('#employeelineManager').html(employeeInfo);
}