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?