4

I want to bind multiple SharePoint Group to Client Side People Picker Using JavaScript.

Requirement as below.

I have two SharePoint group Group 1 and Group 2. I am able to bind group 1 by sending group id to below function, but when I send group id of group 1 and group 2 then it is does not bind to both group.

Below is my code

function CAS_initializePeoplePicker(peoplePickerElementId, multiple, GroupId) {
    try {
        var schema = {};
        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
        schema['SearchPrincipalSource'] = 15;
        schema['ResolvePrincipalSource'] = 15;

        if(!multiple && multiple != undefined){
            schema['AllowMultipleValues'] = false;
        }
        else {
            schema['AllowMultipleValues'] = true;
        }
        if (GroupId != undefined) {
                schema['SharePointGroupID'] = GroupId;
            }

        schema['MaximumEntitySuggestions'] = 50;
        schema['Width'] = '280px';
        this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
    }
    catch (err) {
        console.log(err);
    }
    finally {
        $('#' + peoplePickerElementId + '_TopSpan_InitialHelpText').text('Enter User Name');
    }
}    
2

I don't think you can bind to multiple GroupIDs. The ClientPeoplePickerQueryParameters.SharePointGroupID property is a System.Int32. If you look in the GUI settings when adding a Person or Group field you are only allowed to chose one group. I could be wrong, never tried it. But an easy option could be to add multiple pickers, one pr group.

1
  • Is it possible to bind it multiple members of single group into the client-side people picker? Feb 25 '19 at 16:18

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.