I am creating an app with Power Apps and I am using a couple of SharePoint lists. I am using the StartScreen with an if statement in it to send the user to the appropriate screen, depending on their role and if they are listed in my LAB_LEADERS SharePoint list. That list has 2 fields:
LEADER_NAME - person column
ACTIVE - boolean column
In the StartScreen I have the following if statement:
If(
IsBlank(LookUp(LAB_LEADERS, LEADER_NAME.Email = User().Email && ACTIVE = true)), LeaderDashboardScreen,
IsBlank(LookUp(LAB_POLICY_MONITORS, MONITORS_NAME.Email = User().Email && ACTIVE = true)), LabViewScreen,
IsBlank(LookUp(LAB_RECORD_OWNERS, Record_Owner.Email = User().Email && actuve = true)), LabViewScreen,
IsBlank(LookUp(LAB_POCS, 'POC NAME'.Email = User().Email && ACTIVE = true)), LabViewScreen, UnauthorizedViewScreen
)
My name is listed in the LAB_LEADERS list and I've set ACTIVE to true, when I open the app, I'm taken to the LeaderDashboardScreen. My name is also in the other lists and depending if ACTIVE is true, I go to the appropriate pages.
The issue occurs when my co-workers access the site, they are taken to the LeaderDashboardScreen, even when their names aren't in the LAB_LEADERS list. I was questioning my logic and I added !IsBlank to all those lines in the If statement and those didn't work either.
Any recommendations?
Solved! Go to Solution.
Please consider changing your Formula to the following:
With({_userEmail: User().Email
If(
LookUp(LAB_LEADERS, StartsWith(LEADER_NAME.Email, _userEmail) && ACTIVE, true), LeaderDashboardScreen,
LookUp(LAB_POLICY_MONITORS, StartsWith(MONITORS_NAME.Email, _userEmail) && ACTIVE, true), LabViewScreen,
LookUp(LAB_RECORD_OWNERS, StartsWith(Record_Owner.Email, _userEmail) && actuve, true), LabViewScreen,
LookUp(LAB_POCS, StartsWith('POC NAME'.Email, _userEmail) && ACTIVE, true), LabViewScreen,
UnauthorizedViewScreen
)
)
Comparing the User email and the email in the list should be done with the StartsWith operator to avoid any letter case issues. However, this is a side-point and that issue typically causes the lookup to NOT find anything.
Your LookUp should return what you want to return. In this case, you want the lookup to return a 'true' if the record is found. So, the above has that logic in it. The lookup returns 'true' if found, it will be false otherwise.
I hope this is helpful for you.
Please consider changing your Formula to the following:
With({_userEmail: User().Email
If(
LookUp(LAB_LEADERS, StartsWith(LEADER_NAME.Email, _userEmail) && ACTIVE, true), LeaderDashboardScreen,
LookUp(LAB_POLICY_MONITORS, StartsWith(MONITORS_NAME.Email, _userEmail) && ACTIVE, true), LabViewScreen,
LookUp(LAB_RECORD_OWNERS, StartsWith(Record_Owner.Email, _userEmail) && actuve, true), LabViewScreen,
LookUp(LAB_POCS, StartsWith('POC NAME'.Email, _userEmail) && ACTIVE, true), LabViewScreen,
UnauthorizedViewScreen
)
)
Comparing the User email and the email in the list should be done with the StartsWith operator to avoid any letter case issues. However, this is a side-point and that issue typically causes the lookup to NOT find anything.
Your LookUp should return what you want to return. In this case, you want the lookup to return a 'true' if the record is found. So, the above has that logic in it. The lookup returns 'true' if found, it will be false otherwise.
I hope this is helpful for you.
The solution worked for the most part. I think there is a missing curly bracket, but I was able to overcome that, but leaving off the With statement and just utilized user().Email. I'm sure that there is probably a good reason for assigning the user().Email to a value, but wanted to get the application to work, and it does.
The solution worked for the most part. I think there is a missing curly bracket, but I was able to overcome that, but leaving off the With statement and just utilized user().Email. I'm sure that there is probably a good reason for assigning the user().Email to a value, but wanted to get the application to work, and it does.
User | Count |
---|---|
262 | |
110 | |
98 | |
54 | |
39 |