Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office UI Fabric People Picker Not Supporting Sharepoint group #161

Closed
vaishali-udupa opened this issue Oct 24, 2018 · 14 comments
Closed

Office UI Fabric People Picker Not Supporting Sharepoint group #161

vaishali-udupa opened this issue Oct 24, 2018 · 14 comments
Milestone

Comments

@vaishali-udupa
Copy link

<PeoplePicker context={this.props.webpartContext}
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

@vlad-nvs
Copy link

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

@sympmarc
Copy link

sympmarc commented Dec 19, 2018

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.

@estruyf
Copy link
Member

estruyf commented Dec 20, 2018

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.

@sympmarc
Copy link

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!

@estruyf
Copy link
Member

estruyf commented Dec 20, 2018

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.

@sympmarc
Copy link

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?

@estruyf
Copy link
Member

estruyf commented Dec 20, 2018

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]

@estruyf
Copy link
Member

estruyf commented Dec 20, 2018

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

@sympmarc
Copy link

sympmarc commented Dec 20, 2018

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

@estruyf
Copy link
Member

estruyf commented Dec 20, 2018

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

@estruyf estruyf added this to the 1.11.0 milestone Dec 20, 2018
@sympmarc
Copy link

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.

@vlad-nvs
Copy link

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

Thanks Vladyslav

@estruyf
Copy link
Member

estruyf commented Dec 21, 2018

@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.

@estruyf
Copy link
Member

estruyf commented Dec 21, 2018

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.

@estruyf estruyf closed this as completed Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants