Skip to main content
Improved Content
Source Link
Yayati
  • 1.7k
  • 4
  • 16
  • 36

You can do this by checking On Control Resolved Users Changed event for the Client People picker. Please find more info here for Client People Picker Events.

You can try following script block to check if user is already entered in people picker. Put this script at the end of initializePeoplePicker function definition as defined in your mentioned link

this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) {
    console.log('inside OnUserResolvedClientScript');
    var users = selectedUsersInfo;
    for(var i = 0; i < users.length - 1; i++){
        if(users[users.length - 1].Key == users[i].Key){
            alert("User already exists");
            // Do something else...
        }

    }
};

You can do this by checking On Control Resolved Users Changed event for the Client People picker. Please find more info here for Client People Picker Events.

You can try following script block to check if user is already entered in people picker.

this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) {
    console.log('inside OnUserResolvedClientScript');
    var users = selectedUsersInfo;
    for(var i = 0; i < users.length - 1; i++){
        if(users[users.length - 1].Key == users[i].Key){
            alert("User already exists");
        }

    }
};

You can do this by checking On Control Resolved Users Changed event for the Client People picker. Please find more info here for Client People Picker Events.

You can try following script block to check if user is already entered in people picker. Put this script at the end of initializePeoplePicker function definition as defined in your mentioned link

this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) {
    console.log('inside OnUserResolvedClientScript');
    var users = selectedUsersInfo;
    for(var i = 0; i < users.length - 1; i++){
        if(users[users.length - 1].Key == users[i].Key){
            alert("User already exists");
            // Do something else...
        }

    }
};
Source Link
Yayati
  • 1.7k
  • 4
  • 16
  • 36

You can do this by checking On Control Resolved Users Changed event for the Client People picker. Please find more info here for Client People Picker Events.

You can try following script block to check if user is already entered in people picker.

this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) {
    console.log('inside OnUserResolvedClientScript');
    var users = selectedUsersInfo;
    for(var i = 0; i < users.length - 1; i++){
        if(users[users.length - 1].Key == users[i].Key){
            alert("User already exists");
        }

    }
};