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 / Screen Permissions and...
Power Apps
Answered

Screen Permissions and Error Messages

(0) ShareShare
ReportReport
Posted on by 327

I am trying to improve an app that I have by reducing the amount of screens by reusing one screen that filters a gallery based on a button on another screen.  In this scenario I have users from various sections in the organization.  Each user should only be able to access their section's screen on the app.  This is the code I started with that checks to make sure the logged in user's email is on the SharePoint list and the permissions column has the correct specified value.

 

 

Button Screen
Button OnSelect=

If(
 !IsBlank(
 LookUp(
 DataSource, 
 varUser='UserEmail'.Email And (Permissions.Value = "Section1" Or Permissions.Value = "ADMIN-ALL")
 ).'UserEmail'
 ),
 Navigate(ScrFilter), 
UpdateContext({varShowPopUp1: true}) /*Display access error if email and permission does not match what is on the SharePoint list */
);

 

 

 

This is code I am using now checks the email address, permissions, and section on the SharePoint list.  If all three columns are good to go, the app navigates to the filter screen.

 

 

Button Screen
Button OnSelect=

If(
 !IsBlank(
 Set(
 varSection,
 LookUp(
 DataSource,
 varUser = 'UserEmail'.Email And (Permissions.Value = "Section1" Or Permissions.Value = "ADMIN-ALL")
 ).Section
 )
 ),
 Navigate(ScrFilter),
 UpdateContext({varShowPopUp1: true})
);

Filter Screen 
Gallery Items=
Filter(DataSource, Section=varSection)

 

 

 

There are no errors with the update code but I don't think the If statement is doing anything.  If the email, permission, and section columns do not match with the logged in user, the app still navigates to the filter screen.  No items are displayed which tells me the gallery filter does work, but I do not want the users to get that far.  

 

How can I change the updated code so that it goes to UpdateContext ({varShowPopUp1: true}) instead of navigating to the filter screen?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,291 Most Valuable Professional on at

    Hi @Alex-W ,

    Not sur why you are using a Variable in the middle of this, but the below should work

    If(
     !IsBlank(
     LookUp(
     DataSource,
     varUser = 'UserEmail'.Email And 
     (
     Permissions.Value = "Section1" Or 
     Permissions.Value = "ADMIN-ALL"
     )
     ).Section
     ),
     Navigate(ScrFilter),
     UpdateContext({varShowPopUp1: true})
    );

     

    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.

    Visit my blog Practical Power Apps

  • Alex-W Profile Picture
    327 on at

    @WarrenBelz The code you posted is, for the most part, the same code I started with.  I am setting the variable so that I can pass the section value to the filter screen to filter the gallery.  So, if I stick with the original code, how can I use one screen with a filtered gallery based on the button that is selected on another screen?

  • Verified answer
    WarrenBelz Profile Picture
    155,291 Most Valuable Professional on at

    @Alex-W ,

    OK I see what you are doing now - try this

    Set(
     varSection,
     LookUp(
     DataSource,
     varUser = 'UserEmail'.Email And (Permissions.Value = "Section1" Or Permissions.Value = "ADMIN-ALL")
     ).Section
    );
    If(
     !IsBlank(varSection),
     Navigate(ScrFilter),
     UpdateContext({varShowPopUp1: true})
    );
    

     

    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.

    Visit my blog Practical Power Apps

  • Alex-W Profile Picture
    327 on at

    @WarrenBelz Brilliant!! That worked!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,027

#2
Valantis Profile Picture

Valantis 644

#3
11manish Profile Picture

11manish 626

Last 30 days Overall leaderboard