I want to implement vertical gallery for my SharePoint document library. I want to display documents only where logged in user has edit rights. How can I apply this filter to check if user has access to that docs or not and only list those items on Power Apps. I am using SharePoint connector.
You can use a Power Automate Flow to Get User Permissions - this flow will retrieve the user's permissions for each document and returns a list of documents the user can edit. Your Power Apps gallery will then use the output of this flow.
High-level steps which you can use in a flow:
Trigger: "Power Apps" trigger. This will receive the user's email address from Power Apps.
Get user profile (SharePoint): Use this action to retrieve details about the user.
Get files (properties only) (SharePoint): Use this action to retrieve only the metadata (including item ID) of the files in your document library. Don't retrieve the file content yet. This is important for performance.
Loop (Apply to each): Loop through the files retrieved in the previous step.
Get item permissions (SharePoint):Inside the loop, use this action, providing the file's item ID. This will return the permissions for the specific file.
Condition: Check if the current user has "Edit" permissions in the returned permissions object. The structure of the returned permissions object might vary slightly, but it will usually contain a property or role definition stating the permissions for the user. The condition might look similar to:
contains(items('Apply_to_each')?['d']?['Roles']?['results'], 'Editor') // or similar, adjust as needed
{
"d": {
"Roles": {
"results": [
"Reader",
"Editor" // The user has Editor access
]
}
}
}
Append to Array Variable: If the condition is true (user has edit permissions), append the file's metadata (e.g., file name, URL, etc.) to an array variable.
Response (Power Apps): After the loop, send the array variable back to Power Apps.
You can send the response of this flow back to Power Apps.
Was this reply helpful?YesNo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.