I am creating an app that has two button, Employee Access and Manager Access. When a user clicks the Manager Access button, I want the user to be compared to the Manager list in Collections (a SP list). I was thinking of using an IF statement on the OnSelect of the button. I'm using a similar layout as the Request Leave template. Unfortunately, the template isn't complete in that anyone can click on the Manager button. Thanks in advance.
This is what I currently have in the OnSelect:
Set(_managerView,true);
Navigate(ManagerApproveScreen,None)
Solved! Go to Solution.
The User() function can give details about the current user. For instance, User().Email would return something like robert@yourcompany.com
Assuming all managers in ManagerList have their email in a column named MgrEmail you could check if they are on the list using the following code.
Not(IsBlank(LookUp(ManagerList,MgrEmail=User().Email,MgrEmail)))
You could even put it in the Visible property of your button to make the button disappear when not a manager.
If(Not(IsBlank(LookUp(ManagerList,MgrEmail=User().Email,MgrEmail))),true,false)
Hopefully this points you in the right direction. Note: you could also try User().FullName which would return something like "John Smith" but you might encounter duplicate names.
---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."
The User() function can give details about the current user. For instance, User().Email would return something like robert@yourcompany.com
Assuming all managers in ManagerList have their email in a column named MgrEmail you could check if they are on the list using the following code.
Not(IsBlank(LookUp(ManagerList,MgrEmail=User().Email,MgrEmail)))
You could even put it in the Visible property of your button to make the button disappear when not a manager.
If(Not(IsBlank(LookUp(ManagerList,MgrEmail=User().Email,MgrEmail))),true,false)
Hopefully this points you in the right direction. Note: you could also try User().FullName which would return something like "John Smith" but you might encounter duplicate names.
---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."
This work perfectly. Thank you.
This my change just in case someone in the future wants to navigate to a different screen when not logging in as a manager.
If(Not(IsBlank(LookUp(Managers,Title=varCurrentUser.Mail,Title))),Navigate(ManagerApproveScreen,None),Navigate(myLeaveScreen,None))
Title is just the field in my SP list where I stored the department managers email.
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
267 | |
225 | |
76 | |
38 | |
38 |
User | Count |
---|---|
339 | |
224 | |
121 | |
71 | |
57 |