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

Some of the SharePoint Online users are not showing in the Auto Complete or People Picker #3046

Closed
bhoomesh-spe opened this issue May 29, 2024 · 5 comments

Comments

@bhoomesh-spe
Copy link

What version of PnPjs library you are using

3.x

Minor Version Number

3.15.0

Target environment

SharePoint Framework

Additional environment details

SharePoint Online, SPFx React

Question/Request

Hello Everyone,

I have added Everyone except external users to the Team Site Visitors group. Below is the screenshot for the same.
Screenshot 2024-05-30 001747

Now I have tried to search for one user in the People Picker but the user does not appear in the search results. Below is the screenshot for the same.
Screenshot 2024-05-30 002025

The user I have searched in the auto-complete is the user of our organization. Below is the screenshot for the same.
Screenshot 2024-05-30 002147

I have used the below code for getting site users from the SharePoint User Information list.

export const getSharepointUser = async () => {
    const sp: SPFI = getSP();
    return sp.web.siteUserInfoList.items
        .select("*,ID,Title,Name,EMail,JobTitle,SipAddress,WorkPhone,MobilePhone").getAll()
        .then((res) => {
	    console.log("res..", res);
            return res;
        })
        .catch((err) => {
            console.log("err..", err);
            throw err;
        });
};

Why did the user not appear in the search? Does anyone have an idea?

Thanks

@juliemturner
Copy link
Collaborator

@bhoomesh-spe - Because users are not added to the hidden siteUserInfoList until either a) they access the site or b) you call ensureUser for their user id. If you want to just "search" for a user, you should use the search endpoint instead which at this point is most easily done with SharePoint Search -- you'll want to make sure your search includes the sourceId for People which is the same for every tenant -- but also can be done with Microsoft Graph Search

SharePoint Search example

  const q: SearchQueryInit = SearchQueryBuilder(`${searchString}`)
        .sourceId("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31")
        .rowLimit(500)
        .rowsPerPage(500)
        .selectProperties("SipAddress", "PreferredName", "AccountName", "Department", "JobTitle")
        .trimDuplicates;
  const people: SearchResults = await this._sp.search(q);

@bhoomesh-spe
Copy link
Author

@juliemturner - Thanks for the quick response. Can we load all users for the site using the PowerShell script? i.e. The admin can run the script from SharePoint Online Management Shell and all users appear in the search.

@patrick-rodgers
Copy link
Member

@bhoomesh-spe - while we try and be helpful, this is not a general support forum. Yes, you can load all the users from a PowerShell script, but that has nothing to do with PnPjs so we're not able to provide that guidance. Will close this issue as answered. Thanks!

@juliemturner
Copy link
Collaborator

I'm just going to add, all the users already show in search just not in the site's hidden user list. Search is not the intent of the hidden user list it's a lookup list for any User based list/site columns.

Copy link

github-actions bot commented Jun 2, 2024

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants