rest - How to fetch people from a specific sharepoint group to ClientPeoplePicker in Sharepoint Online?
问题描述
I have tried using ClientPeoplePickerSearchUser. Can anybody help me out? I have followed link : http://sharepointfieldnotes.blogspot.com/2014/06/sharepoint-2013-clientpeoplepicker.html
解决方案
You need set "SharePointGroupID" property in the code to limit search people from a specific SharePoint group in client people picker.
function search(request,response) {
var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
var restSource = appweburl + "/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser";
var principalType = this.element[0].getAttribute('principalType');
$.ajax(
{
'url':restSource,
'method':'POST',
'data':JSON.stringify({
'queryParams':{
'__metadata':{
'type':'SP.UI.ApplicationPages.ClientPeoplePickerQueryParameters'
},
'AllowEmailAddresses':true,
'AllowMultipleEntities':false,
'AllUrlZones':false,
'MaximumEntitySuggestions':50,
'PrincipalSource':15,
'PrincipalType': principalType,
'QueryString':request.term
//'Required':false,
'SharePointGroupID':23,
//'UrlZone':null,
//'UrlZoneSpecified':false,
//'Web':null,
//'WebApplicationID':null
}
}),
'headers':{
'accept':'application/json;odata=verbose',
'content-type':'application/json;odata=verbose',
'X-RequestDigest':requestDigest
},
'success':function (data) {
var d = data;
var results = JSON.parse(data.d.ClientPeoplePickerSearchUser);
if (results.length > 0) {
response($.map(results, function (item) {
return {label:item.DisplayText,value:item.DisplayText}
}));
}
},
'error':function (err) {
alert(JSON.stringify(err));
}
}
);
}
推荐阅读
- python - Python:重新排列方程以采用特定形式
- c# - 如何获取鼠标相对于世界的坐标?
- python - TypeError:“RelatedManager”对象不可迭代 - serializers.ListField()
- xamarin.forms - 在 Xamarin.forms 中从 Json 写入文本文件(或 PDF 文件)
- arrays - 如何在swift中过滤对象的3维数组
- python - 将文件从客户端上传到服务器时出现问题
- python - 如何更改 QCombobox 下拉项背景颜色的颜色
- javascript - Puppeteer page.mouse.down() / up() 和点击物理鼠标不一样?
- python - 用于下载 Youtube 视频的 Python 中的 Pytube 错误
- javascript - IOS 设备上的 HTML 或 Javascript Base64 文件上传存在大文件问题