cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Responsive Resident
Responsive Resident

Button Click to be allowed to Specific Users

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,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User III
Super User III

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.

View solution in original post

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,

View solution in original post

8 REPLIES 8
Super User III
Super User III

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.

View solution in original post

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

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 

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.



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
)

@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?

Hello @WarrenBelz , @JLincoln ,

 

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

 

Thanks,

Akshay

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,

View solution in original post

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (38,560)