Skip to main content

Notifications

Community site session details

Community site session details

Session Id : jylvLppTsaKxe0Jd2oCzon
Power Apps - Building Power Apps
Answered

Display button if user is part of the SharePoint owners security group

Like (1) ShareShare
ReportReport
Posted on 2 Aug 2023 19:22:10 by 401

Hi,

 

Is there a way to show/hide a button if the current user belongs to the SharePoint Owners security group? 

 

Thanks in advance.

  • gelno Profile Picture
    3 on 26 Jan 2024 at 21:46:14
    Re: Display button if user is part of the SharePoint owners security group

    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!

  • _sourcecod3_ Profile Picture
    401 on 05 Aug 2023 at 15:12:26
    Re: Display button if user is part of the SharePoint owners security group

    hi @poweractivate   This worked perfectly. Thank you so much. 

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on 02 Aug 2023 at 19:30:23
    Re: Display button if user is part of the SharePoint owners security group

    @_sourcecod3_ 

    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.

     

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.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading complete