cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Button Click to be allowed to Specific Users

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

7 REPLIES 7
Highlighted
Super User III
Super User III

Re: Button Click to be allowed to Specific Users

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

Highlighted
Helper V
Helper V

Re: Button Click to be allowed to Specific Users

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

Highlighted
Helper V
Helper V

Re: Button Click to be allowed to Specific Users

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 

Highlighted
Super User III
Super User III

Re: Button Click to be allowed to Specific Users

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.

Highlighted
Frequent Visitor

Re: Button Click to be allowed to Specific Users



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
)

Highlighted
Super User III
Super User III

Re: Button Click to be allowed to Specific Users

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

Highlighted
Helper V
Helper V

Re: Button Click to be allowed to Specific Users

Hello @WarrenBelz , @JLincoln ,

 

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

 

Thanks,

Akshay

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,475)