Question

In a web part, I wanted to show only items that people had permissions on. I know I can stop inheriting permissions on the list and give them unique permissions, but that's not what our client wants. So we created a column of people and groups (linked to Azure AD groups) we wanted to be able to filter in the search query only items where the user belonged to the group the item is associated with. Is this possible?

Thank you.

Was it helpful?

Solution

You can use the REST API to get the current user's groups:

[your-site-url]/_api/web/currentuser/?$expand=groups

Create an array of the group IDs and/or names.

Then filter your search results by items that have at least one of the user's groups in your custom column. You can map or loop the array of the current user's groups to dynamically generate your querytext.

Note: To use your custom column as a search filter, you might need to map it to a reusable refinable property in your Search Schema, such as RefinableString00 or RefinableInt33.

Hope this helps. Let me know if you'd like more details.

OTHER TIPS

This is not achievable by OOB solution.

Besides what Ben suggests, here are some posts with similar request that might be helpful to you.

References:

Trim search results based on user permissions.

Filter List View / CQWP/ DVWP by Current Users Department.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top