【问题标题】:How to use @pnp/sp to retrieve users for a People Picker如何使用@pnp/sp 为人员选择器检索用户
【发布时间】:2019-08-19 18:55:48
【问题描述】:

我不知道如何使用人员选择器和@pnp/sp 在我的租户中检索用户的好示例。

我尝试使用 GitHub 上的 @pnp/sp 手册。还有一些教程,但没有提到如何查询 Office 365 租户。

这是渲染中的人物选择器:

 <PeoplePicker
            context={this.props.context}
            titleText="People Picker"
            personSelectionLimit={3}
            groupName={''}
            showtooltip={true}
            isRequired={true}
            disabled={true}
            selectedItems={this._getPeoplePickerItems}
            showHiddenInUI={false}
            principalTypes={[PrincipalType.User]}
            resolveDelay={1000} 
            />  

这是我的空函数,准备好等待那行神奇的代码。

private _getPeoplePickerItems(items: any[]) {
    console.log('Items:', items);
  }

我希望人员选择器查询我的租户并向我显示我的租户中的用户。目前它显示无法找到 Group,但我当然明白为什么。

【问题讨论】:

    标签: sharepoint-online spfx


    【解决方案1】:

    获取用户列表,调用/_api/_web/siteusers

    或者:

    $pnp.sp.web.siteUsers.get().then(function(data) {
        //to do
    });
    

    【讨论】:

    • 我使用了您的建议将其缩短为 private _getPeoplePickerItems() { pnp.sp.web.siteUsers.get(); }
    猜你喜欢
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多