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,
Solved! Go to Solution.
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.
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,
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.
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
)
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,
User | Count |
---|---|
224 | |
99 | |
95 | |
57 | |
31 |
User | Count |
---|---|
283 | |
113 | |
107 | |
63 | |
61 |