Refer the following script files in your page,
<!-- For People Picker -->
<script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="/_layouts/15/autofill.js"></script>
<!--- -->
Now we have to create a div for our custom people picker control
<div id="dvPicker">
</div>
Now paste the following script which can restrict the custom people picker for one group.
Here we have to pass the Group name to get the corresponding Group ID
<script type="text/javascript">
var reviewGroupId;
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {
(function () {
LoadInitial();
})();
});
function LoadInitial() {
var requestUri =_spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteGroups/getbyname('Board')";
$.ajax({
url: requestUri,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
}
function onSuccess(data) {
reviewGroupId = data.d.Id;
alert(reviewGroupId);
initializePeoplePicker('dvPicker', reviewGroupId);
}
function onError(error) {
alert(JSON.stringify(error));
}
function initializePeoplePicker(peoplePickerElementId, Id) {
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = false;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
schema['SharePointGroupID'] = Id;
SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
}
</script>
Here we are restricting the people picker for only one SharePoint group "Board".
Apart from this group other group users will not resolve in this people picker.
Thanks,
<!-- For People Picker -->
<script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="/_layouts/15/autofill.js"></script>
<!--- -->
Now we have to create a div for our custom people picker control
<div id="dvPicker">
</div>
Now paste the following script which can restrict the custom people picker for one group.
Here we have to pass the Group name to get the corresponding Group ID
<script type="text/javascript">
var reviewGroupId;
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {
(function () {
LoadInitial();
})();
});
function LoadInitial() {
var requestUri =_spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteGroups/getbyname('Board')";
$.ajax({
url: requestUri,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
}
function onSuccess(data) {
reviewGroupId = data.d.Id;
alert(reviewGroupId);
initializePeoplePicker('dvPicker', reviewGroupId);
}
function onError(error) {
alert(JSON.stringify(error));
}
function initializePeoplePicker(peoplePickerElementId, Id) {
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = false;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
schema['SharePointGroupID'] = Id;
SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
}
</script>
Here we are restricting the people picker for only one SharePoint group "Board".
Apart from this group other group users will not resolve in this people picker.
Thanks,