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.
Solved! Go to Solution.
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:
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,
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)
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.
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.
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:
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,
Thanks for posting in the community @Oskarkuus - can you review the above replies and update the thread if they were helpful?
Thank you,
@Anonymous
User | Count |
---|---|
212 | |
94 | |
85 | |
49 | |
38 |
User | Count |
---|---|
271 | |
104 | |
102 | |
60 | |
59 |