cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Oskarkuus
Level: Powered On

How to set visible true / false - based on AD group and/or O365 group membership?

How can i set a button to be visible (true/false) if a user is member of a AD group or a office365 group.

 

I want to hide a button if the user using my app is not part of a specific group.

 

A way to control permission and make it easer for the user to use the application.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to set visible true / false - based on AD group and/or O365 group membership?

Hi @Oskarkuus ,

Do you want to visible the Button if a specific user is a member of your AD group or your Office 365 group?

 

I have made a test on my side, please take a try with the following workaround:2.JPG

 

3.JPG

I assume that you want to check if a user is in your Office 365 group. I have made a test on my side, please take a try with the following workaround:

Set the Items property of the Dropdown box (Dropdown1) to following:

Office365Groups.ListOwnedGroups().value

then set the displayName property as display value within the Dropdown box.

 

Set the Visible proeprty of the "TARGET BUTTON" to following:

If(
    User().Email in Office365Groups.ListGroupMembers(Dropdown1.Selected.id).value.mail,
    true,
    false
)

On your side, you should type the following formula:

If(
    "The email of a specific user" in Office365Groups.ListGroupMembers("The Group Id of a Office 365 group").value.mail,
    true,
    false
)

Note: 'The Group Id of a Office 365 group' looks like this "57efb8ae-2d32-4b04-807c-73550848af7b" -- a GUID string.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Super User
Super User

Re: How to set visible true / false - based on AD group and/or O365 group membership?

Hi @Oskarkuus,

If you have a datasource, for example, ds,  that includes the full name or email of the user, you can use the User().FullName or User().email to test for membership.  You would set the Visible property of the button to 

Lookup(ds, username=User.FullName)

this formula resolves to either true or false.  If you have two datasources and you wish to test for membership in either group the formula would be

Lookup(ds1, username=User.FullName)  || Lookup(ds2, username=User.FullName) 

If it was necessary that the user be a member of both groups then the formula would be 

Lookup(ds1, username=User.FullName)  && Lookup(ds2, username=User.FullName) 
Oskarkuus
Level: Powered On

Re: How to set visible true / false - based on AD group and/or O365 group membership?

But that means i need a datasource setup to mirror an AD group or office365 group.

I want to set the permissions based on the groups directly and not create a List or excel file with usernames or emailadresses.

 

 

Super User
Super User

Re: How to set visible true / false - based on AD group and/or O365 group membership?

@Oskarkuus 

You could use the AzureAD connector in your App to do this.

You will need the GUID of the group you are checking.

Put a formula such as this in your OnStart:

   Set(groupMember, CountRows(AzureAD.CheckMemberGroups(User().Email, {Value:"your-group-guid-here"}))=1)

 

Then set the visible property of your button to this:

   groupMember

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: How to set visible true / false - based on AD group and/or O365 group membership?

Hi @Oskarkuus ,

Do you want to visible the Button if a specific user is a member of your AD group or your Office 365 group?

 

I have made a test on my side, please take a try with the following workaround:2.JPG

 

3.JPG

I assume that you want to check if a user is in your Office 365 group. I have made a test on my side, please take a try with the following workaround:

Set the Items property of the Dropdown box (Dropdown1) to following:

Office365Groups.ListOwnedGroups().value

then set the displayName property as display value within the Dropdown box.

 

Set the Visible proeprty of the "TARGET BUTTON" to following:

If(
    User().Email in Office365Groups.ListGroupMembers(Dropdown1.Selected.id).value.mail,
    true,
    false
)

On your side, you should type the following formula:

If(
    "The email of a specific user" in Office365Groups.ListGroupMembers("The Group Id of a Office 365 group").value.mail,
    true,
    false
)

Note: 'The Group Id of a Office 365 group' looks like this "57efb8ae-2d32-4b04-807c-73550848af7b" -- a GUID string.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

TopShelf-MSFT
Level 10

Re: How to set visible true / false - based on AD group and/or O365 group membership?

Thanks for posting in the community @Oskarkuus - can you review the above replies and update the thread if they were helpful? 

 

Thank you,

 

@TopShelf-MSFT 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,284)