Hi,
Is there a way to show/hide a button if the current user belongs to the SharePoint Owners security group?
Thanks in advance.
Hi!
I had the exact same need as the original poster. I followed your instructions and think I got everything correct. I get to your very last step (2 b as you have them written out) and cannot seem to get the Visible property to be happy with:
'Owners' in colUserGroups
Two questions.
1) Wouldn’t it be Owner, not Owners as the SharePoint site permissions labels someone as Owner?
2) Can you share the exact syntax or screenshot of how this should be written in the Visible property? I have tried many variations, some including an If statement. Currently I have:
’Owner’ in colUserGroup
and I get an error that says:
‘Owner’ isn’t recognized
If I understand the in operator correctly, it produces true/false without the need of an If statement.
Thanks in advance for any help or direction you can give!
hi @poweractivate This worked perfectly. Thank you so much.
Yes, you can try to conditionally show/hide a button based on the current user's group membership in SharePoint.
However, Power Apps itself doesn't really have a direct formula to fetch SharePoint group membership of the current user to my awareness.
You would need to instead, create a flow in Power Automate that gets the SharePoint group membership and then call this flow from Power Apps.
Here's how you could do this:
1. Create a flow in Power Automate:
a. The trigger should be PowerApps (V2)
b. Add a Send an HTTP request to SharePoint action. Site Address is your SharePoint site URL. Method should be GET. Uri is _api/web/currentuser/groups.
c. Parse the JSON result to get the group titles. Add a Parse JSON action. Content is body('Send_an_HTTP_request_to_SharePoint')?['d']?['results']. Schema can be generated from a sample payload, which you can get by running the HTTP request in a browser.
d. Initialize an array variable. Loop over the parsed results using Apply to each, and add the group titles to the array using Append to array variable.
e. Finally, add a Respond to a PowerApp or flow action and provide the array variable as input.
2. In Power Apps, call the flow and get the result:
a. On App start, use ClearCollect(colUserGroups, YourFlowName.Run()) to run the flow and store the returned groups in a collection.
b. Use the in operator to check if 'Owners' is in the returned groups. The Visible property of the button would be: 'Owners' in colUserGroups.
Please note that the flow runs with the permissions of the current user, so it can only see the groups that the user has permissions to see.
WarrenBelz
146,745
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional