Closed bhoomesh-spe closed 5 months ago
Have you tried anything? What solutions did you research that didn't work?
I have tried the below code but it is not working due to threshold limitation.
import { spfi } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/site-users/web";
const sp = spfi(...);
const users = await sp.web.siteUsers.orderBy("Title", true).top(10000)();
console.log("users: ", users);`
Hi, you can't select top 10000. The max is 5,000. So you'll need to set up your own logic to loop through after each top(5000). Potentially, you would order by id descending, and on subsequent calls just do a filter for gt than your last highest id.
Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!
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.
What version of PnPjs library you are using
3.x
Minor Version Number
3.15.0
Target environment
All
Additional environment details
SharePoint Online, SPFx, React
Question/Request
Hello Everyone,
I have tried to get all site users programmatically using the below code.
The above code is working as expected if the site contains less than 5000 users.
But if the site contains more than 5000 users what changes need to do in the above code?
Can anyone help me with the same?
Thanks