cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
myka
Frequent Visitor

Comparing Person field value with User().Email in Power Apps

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?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@myka 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@myka 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
myka
Frequent Visitor

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.

myka
Frequent Visitor

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.

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,599)