Sp-dev-fx-controls-react: Office UI Fabric People Picker Not Supporting Sharepoint group

Created on 24 Oct 2018  路  14Comments  路  Source: pnp/sp-dev-fx-controls-react

titleText="Author's" personSelectionLimit={3}
groupName={""} // Leave this blank in case you want to filter from all users
showtooltip={true}
selectedItems={this._getPeoplePickerItems}
showHiddenInUI={false}
principleTypes={[PrincipalType.User,PrincipalType.SharePointGroup]} />

[ ] Question
I am not able to get the Sharepoint groups using the ,PrincipalType.SharePointGroup.

Thanks!
Vaishali

Most helpful comment

Thanks, @estruyf. Now that I'm finally using these controls, they are really awesome. I hope to be able to contribute more as we go along.

All 14 comments

Category
[x ] Bug

I'm also have this issue. Version 1.10.0

After short investigation I can suppose that '/_api/web/siteusers' with filter (PrincipalType eq 8) which used inside '_thisLoadUsers' method in PeoplePickerComponent does not return any SharePoint Group.

Using additional call with '/_api/web/sitegroups' (in case if SharePoint Group should be retrieved) can fix issue.

Thanks
Vladyslav

Probably connected: in version 1.11.0 beta, specifying the groupName doesn't seem to limit the people retrieved. This may be a regression in the re-architecture in 1.11.0.

Example:
groupName={"Shipping & Logistics Team Members"}

From what I can see, the underlying call to /sites/ShippingLogisticsTeam/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUs
is not passing the groupName to the call.

Seems to be indeed a limitation in the siteUsers API. When using the _api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUs API (when not applying the absoluteWebUrl), the groupName was indeed ignored.

I just did an update to the library to always use the _api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUs API and take the groupName into account when provided and will also allow you to search for SharePoint groups. Same logic as the people picker in a list is implemented. A new beta version will be available in a matter of minutes.

It occurred to me overnight that it might not be working for me because I didn't specify the webAbsoluteUrl as well. When I looked into your code yesterday, I saw that you had two different calls, depending on whether that value was provided. But it sounds like you came up with an approach that may work. I'll try it out. Thanks!

Investigated the actual calls that are done in SharePoint lists itself, and using the same logic now. Makes more sense to call one API, instead of three different ones.

I installed the latest, and I'm still seeing everyone in the picker, even when I include:

              groupName={"Shipping & Logistics Team Members"}
              webAbsoluteUrl={"https://tenant.sharepoint.com/sites/ShippingLogisticsTeam"}

Did you push your changes to @pnp/spfx-controls-react@next?

Changes are indeed available on the latest. Normally you should now see a call happening to the _api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUs API for the group name you provided. If the group is not found, control will be disabled and shows a message. So it could be that you have an old version.

Try by installing it like this: npm i @pnp/[email protected]

Just tested it in a new project that I create to be sure it was working correctly. Also created the same group and added one user to it.

<PeoplePicker context={this.props.context}
              titleText='People Picker searching in "Shipping & Logistics Team Members"'
              groupName="Shipping & Logistics Team Members"
              ensureUser={true}
              principalTypes={[PrincipalType.User]}
              selectedItems={(items) => console.log(items)} />

people-picker

Yup, working for me, too. The dread "developer error". Thanks for the help!

Thank @sympmarc for testing! Will release the new version tomorrow.

Thanks, @estruyf. Now that I'm finally using these controls, they are really awesome. I hope to be able to contribute more as we go along.

Hi all. And how about selecting SharePoint groups in this control?

Thanks Vladyslav

@vlad-nvs should work as well right now. If you pass PrincipalType.SharePointGroup to the principalTypes property it should retrieve the SharePoint groups from the site.

This has been released with the latest 1.11.0 version. Feel free to test it out, and you can reopen the issue if it still occurs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

estruyf picture estruyf  路  6Comments

nbelyh picture nbelyh  路  4Comments

shrikantmane picture shrikantmane  路  3Comments

msgx picture msgx  路  4Comments

joelfmrodrigues picture joelfmrodrigues  路  4Comments