web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Button Click to be all...
Power Apps
Answered

Button Click to be allowed to Specific Users

(0) ShareShare
ReportReport
Posted on by 2

Hi,

 

We are developing an app where i have created Admin Page. I have added a button in the Home Screen, and onSelect it Navigates to the Admin Screen. Right now it is just a screen but in future it may be a link. 

 

I want only specific users to be able to click on the button and they should redirect. All the other users, should not be able to click on to the button or they should get a popup that 'It is only for Admins' similar like that.

 

Can anyone please help on this?

 

Regards,

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,117 Most Valuable Professional on at

    Hi @AkshayManke ,

    Create a reference list with the email address of all admins. then at the Button push, add this

    Set(vUserMail,User().Email);
    If(
     IsBlank(
     Lookup(
     YourRefListName,
     YourListEmailField=vUserMail,
     YourListEmailField
     )
     ),
     Notify("This function only for Admins",NotificationType.Error),
     Navigate(YourAdminScreenName)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • AkshayManke Profile Picture
    2 on at

    Hello @WarrenBelz,

     

    The solution suggested by you is working like charm. It is exactly what i was looking for. Accepting as solution.!!

    Thanks a lot for the help @WarrenBelz . !! 🙂

     

    Thanks and Regards,

    Akshay Manke

  • AkshayManke Profile Picture
    2 on at

    Hello @WarrenBelz,

     

    Actually i was using the same code which you few months back. It is working perfectly fine when i am adding or removing my email from the AccessList (Columns = Name, Email),  column but it seems not working with other users case. I tried adding removing multiple times but all users facing issues and they get the notification message even if they are added in the list.

     

    Below the code i am using. Can you please help me understand where i am missing or is there any refresh time it take to take effect on the other users PCs? 

     

    Set(
     vUserMail,
     User().Email
    );
    If(
     IsBlank(
     LookUp(
     AccessList,
     Email = vUserMail,
     Email
     )
     ),
     Notify(
     "You are not a member of 'Review Team' hence the access is denied.",
     NotificationType.Error
     ),
     Navigate(Submission_Screen);
     ResetForm(Form1)
    )

     

    Many Thanks in Advance.

     

    Regards,

    Akshay 

  • WarrenBelz Profile Picture
    156,117 Most Valuable Professional on at

    Hi @AkshayManke ,

    Firstly, this should work with any user, but there may be a case matching issue. assuming your reference list has all lower case, try this

    Set(
     vUserMail,
     User().Email
    );
    If(
     IsBlank(
     LookUp(
     AccessList,
     Email = Lower(vUserMail),
     Email
     )
     ),
     Notify(
     "You are not a member of 'Review Team' hence the access is denied.",
     NotificationType.Error
     ),
     Navigate(Submission_Screen);
     ResetForm(Form1)
    )

    You can also try

    If(
     CountRows(
     Filter(
     AccessList,
     Email = Lower(vUserMail)
     )
     )=0,

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • JLincoln Profile Picture
    69 on at


    Set(
     vUserMail,
     User().Email
    );
    If(
     IsBlank(
     LookUp(
     AccessList,
     Email = vUserMail,
     Email
     )
     ),
     Notify(
     "You are not a member of 'Review Team' hence the access is denied.",
     NotificationType.Error
     ),
     Navigate(Submission_Screen);
     ResetForm(Form1)
    )

     
    LookUp(
        AccessList,
        Email = vUserMail ,
        Email
    )

    Remove the bit in red and it should work. Your lookup is failing because 'Email' is never true.
    LookUp(
        AccessList,
        Email = vUserMail
    )

  • WarrenBelz Profile Picture
    156,117 Most Valuable Professional on at

    @JLincoln ,

    That is untrue - the LookUp needs a field value for IsBlank() to function. Removing the Email reference simply produces a record instead of a single text value, so that is not the problem.

    @AkshayManke , have you tried the CountRows() option or the Lower() reference?

  • AkshayManke Profile Picture
    2 on at

    Hello @WarrenBelz , @JLincoln ,

     

    I will try the options suggested by both of you and will get back in next 4 - 5 hours.

     

    Thanks,

    Akshay

  • Verified answer
    AkshayManke Profile Picture
    2 on at

    Hello @WarrenBelz@JLincoln,

     

    I apologies that i took more time to reply you back. What i found that, the codes which suggested by both of you were correct. However i configured permissions to the List (Read Permission given to all the users from List Settings) then the App worked as expected. I think the user was there in the list but since he/she was not having permissions to access the SP List hence the PowerApp was unable to fetch the permission details from the list and was failing to recognize the permissions. After configuring the permissions the issue got resolved and all the users now are getting the access as per their role.

     

    Many Thanks to both of you for your help.

     

    Regards,

  • Aiyoo_Da Profile Picture
    36 on at

    Similar issue 
    I have a sharepoint list with email id's in one column and role in other. The role column has multiple options; and a person havve one or more roles (like Admin, guest, user, developer etc).. How can i enable or disable access to a button (with the same error message saying you are not authorized)  by checking all of the allotted roles for a person?

  • JLincoln Profile Picture
    69 on at

    @Aiyoo_Da 

    Button.Visible = "AllowedRole" in LookUp(SharePointList, User().Email = EmailID).Role

    e.g. if SharePoint List is {EmailID: "Test@microsoft.com", Role:"Admin, User"}
    Button.Visible = "Admin" in LookUp(SharePointList, User().Email = EmailID).Role

    If you wanted to check multiple roles (e.g. only someone who is both an admin and a developer can see it)
    Button.Visible = "Admin" in LookUp(SharePointList, User().Email = EmailID).Role && "Developer" in LookUp(SharePointList, User().Email = EmailID).Role


    You can set permissions on the OnStart of the app by doing the lookup and getting the roles string, that would prevent you from having as many queries and you'd be able to tell what the user had at the beginning

    UpdateContext({varUserPermissions: LookUp(SharePointList, User().Email = EmailID).Role})

    And then

    Button.Visible = "Admin" in varUserPermissions


    To do the "You are not Authorized" just do
    ErrorMessage.Visible = !Button.Visible

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard