cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EMohaisen
Helper I
Helper I

Filter gallery items based on login user (Very Slow!!)

Hello All, @RandyHayes  

 

I am trying to filter a gallery items based on login user.

I have 2 "Person or Group" fields (Employee & Hirining Manager) from the SharePoint list.

so i would like to see all items where my name is in the hiring manager field or if my name is in the Employee field.

 

I used the following formula but it's very very slow loading the items.. any ideas please?

 

 

Filter(
'NAEOOP Master List',
Or(
'Hiring Manager'.Email = Office365Users.MyProfile().Mail,
'Employee (AD)'.Email = Office365Users.MyProfile().Mail
)
)

 

I tried as well to use the following filter but it's not working:

 

Filter(
'NAEOOP Master List',
Or(
'Hiring Manager'.Email = User().Email,
'Employee (AD)'.Email = User().Email
)
)

 

 

Note: the following will return from my Organization:

Office365Users.MyProfile().Mail => firstname.lastname@company.com

User().Email => Username@company.com

 

Thanks for your help!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@EMohaisen 

Seems unusual that you would be seeing two different email addresses from those functions unless there are multiple aliases assigned to the user.

But at any rate...you really don't want to put those functions in a formula like that as they will slow things down.

Consider putting the correctly returning value in a variable and use that instead - this is usually done in the OnStart of the App as an easy place to do this.

   Set(MyProfileEmail, Office365Users.MyProfile().Mail)

Then in your Filter:

Filter(
    'NAEOOP Master List',
     Or(
       'Hiring Manager'.Email = MyProfileEmail,
       'Employee (AD)'.Email = MyProfileEmail
       )
)

I hope that 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

2 REPLIES 2
RandyHayes
Super User
Super User

@EMohaisen 

Seems unusual that you would be seeing two different email addresses from those functions unless there are multiple aliases assigned to the user.

But at any rate...you really don't want to put those functions in a formula like that as they will slow things down.

Consider putting the correctly returning value in a variable and use that instead - this is usually done in the OnStart of the App as an easy place to do this.

   Set(MyProfileEmail, Office365Users.MyProfile().Mail)

Then in your Filter:

Filter(
    'NAEOOP Master List',
     Or(
       'Hiring Manager'.Email = MyProfileEmail,
       'Employee (AD)'.Email = MyProfileEmail
       )
)

I hope that 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!

@RandyHayes Thanks a LOT!! 

 

Yes, it works very well !! i really appriciate your quick help.

 

Excellent!

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 (2,244)