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 / Restricting navigation...
Power Apps
Answered

Restricting navigation to certain screens with an "IF" statement and PeoplePicker column from a SharePoint list

(0) ShareShare
ReportReport
Posted on by 31

Hello,

I am looking to restrict access to a manager page within my powerapps application. I am wanting to do so by referring to a people picker column I have in a SharePoint list that hosts all the manager's information.

I am wanting to do so by doing something like this on visible property of a label:

If(Datasouce.ManagerPicker.Email = User().email, true, false)

OR

I have explored the option of trying something similar on the OnSelect property:

If(Datasource.ManagerPicker.Email = User().email, Navigate(managerPage),
                                                            Notify("You don't have permission to navigate to that page.", Error))

I am aware that this can be done if I type in a specific email address like so:

If(User().Email = "manager'sEmailAddress", navigate(managerPage), Notify(Error message)

I am trying to avoid that at all costs because there are several managers within the org. and if they change, I will have to manually change the syntax each time. This is why referring to the people picker column would be much easier.

Thanks for any assistance!

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @caleb_abernathy 
    Create a SharePoint list called 'Managers List'.  It should have a single column called 'Manager' which is a People column.  Add a new line for each manager that should be one the list.  Do not allow multiple values in a single field.

     

    Then put this code in the OnStart property of your app.

    Set(isManager, !IsBlank(LookUp('Managers List', Manager.mail = User().Email)))

     
    Now you can use this code in the Visible property of your go to Manager screen button.

    isManager

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • caleb_abernathy Profile Picture
    31 on at

    Thanks for the quick response!

    I set the onStart property of my app to: 
    "Set(isManager, !IsBlank(LookUp('CTP - Processing','ManagerPicker-Test'.Email = User().Email)))"
    And the visible property of the label to: "isManager"

     

    Unfortunately, I had someone who wasn't on the manager list try to sign in and they can still see the lable.
    Do I need to be more specific when it comes to setting the isManager variable?
    Maybe someone denoting if it is true of false within the syntax? Because, right now, it appears that it is returning true for all users for some reason. 

    Thanks!

     

     

  • mdevaney Profile Picture
    29,993 Moderator on at
    @caleb_abernathy
    Are you sure the other users are using the most recent version of the app? Apps have been slower to publish these past few weeks.

    Otherwise, I think the way you’ve written it only people in the 'ManagerPicker-Test' column in the table 'CTP - Processing' can see the label. But keep in mind my suggestion was to create a new table with a single column containing only Managers who should see the button instead.

    —-
    Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
  • caleb_abernathy Profile Picture
    31 on at

    Thanks for the quick response.

    That being said, within the 'ManagerPicker-Test' column, I am the only one in the entire column. (*See attached image*). 
    So, with the logic presented above, I should be the only one that is able to see the labels given the code -- correct?

    managerpicker.PNG
  • caleb_abernathy Profile Picture
    31 on at

    I think it isn't working because we are using a Global Variable. So, whenever I sign in to test it, it remains true since I am a manager. 

    Is there a way to change this to a local variable or make it adjust/reset each time a new user signs in?

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi  @caleb_abernathy ,

     

    I made a test based on @mdevaney 's code, it works well for your case.

    I put code '!IsBlank(LookUp('CTP - Processing','ManagerPicker-Test'.Email = User().Email))' to Visible of button directly, the button only be visible when I was in the SharePoint list person column, If I remove myself from the list and refresh the SP list connection, the button becomes invisible.

    Snipaste_2020-04-02_13-57-30.pngSnipaste_2020-04-02_13-57-24.png

    Could you please create a new canvas app to try again?

    Sik

  • caleb_abernathy Profile Picture
    31 on at

    Hi,

    Thanks for the quick reply.

    As you can see by the *attached image* I used that code exactly the way you stated - on the OnVisible property and my label is still visible for some reason.

    Yes, I did take my name out of the column and refresh the data source. 

    Thanks for any insight.

    ManagerPickerTest.PNG
  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @caleb_abernathy ,

     

    That's odd. Let's try to avoid the impact of the delegation issue. please try this

    1. ensure to take your name out of all row in sharepoint list

    2. save User().Email into a variable to avoid delegation issue, Set App.OnStart: Set(MyEmail, User().Email), Click Run OnStart button to trigger it.

    3. Then try this code to Label.Visible property:

    !IsBlank(LookUp('CTP - Processing','ManagerPicker-Test'.Email = MyEmail))

    Let me know the test result.

    Sik

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard