cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vaishalivyas1
Level: Powered On

Filtering records with current user

Hi,

 

I want to filter records on my browse screen with email of current user.I used Office 365 Users Connection. 

Logic Which I have written on items property of browse screen:

Screenshot_5.png

Error :

Screenshot_6.png

Thanks.

Regards,

Vaishali

1 ACCEPTED SOLUTION

Accepted Solutions
JRaasumaa
Level 10

Re: Filtering records with current user


@vaishalivyas1 wrote:

Hi,

 

I want to filter records on my browse screen with email of current user.I used Office 365 Users Connection. 

Logic Which I have written on items property of browse screen:

Screenshot_5.png

 


 

 

I'm surprised nobody has said this but calling User() in a function is incredibly slow performance wise. If you can, assign the User() to a variable before you use the filtering you will get better performance.

 

For example: On Visible on our Home screen (the first screen the App loads) we have the current user stored in a variable CurrentUser

 

Set(CurrentUser, User())

Then when needed you can perform a lookup on that specific user without calling the User() function by doing things like:

 

If(CurrentUser.FullName = "John Smith", true,false)

 

This helped us speed up all our filtering and added a layer of protecting controls simply by capturing the user once and then referring to the variable throughout the app.

View solution in original post

14 REPLIES 14
Highlighted
Super User
Super User

Re: Filtering records with current user

In your call to Filter you have to compare the database column with User().FullName OR Office365Users..., not compare them to each other.

 

It's not an error as such, it's a warning about delegation that you will only look in the 500 first records.

 

What's your data source, SP, SQL or something else?

vaishalivyas1
Level: Powered On

Re: Filtering records with current user

Hi @BitLord69

 

My DataSouce is Dynamics CRM and i want to filter the records on browse screen of current logged in user.

 

Thanks

Super User
Super User

Re: Filtering records with current user

Yes, it's completely possible to Filter based on the current user, but you have to compare the current user to a field in your db, NOT to your own profile in Office365.

 

That means that in order to do so your database must have a column containing either the full name (which you can get from User().FullName), or the e-mail address (that you get from User().Email). If there is no such field you have to add one, or you cannot filter based on it.

vaishalivyas1
Level: Powered On

Re: Filtering records with current user

Hi @BitLord69

 

Thanks for replying, I don't have fullname or email fields on that entity but I have created by and Owner fields Data Type of that fields are Lookup can I filter based on that?

 

Regards,

Vaishali

Super User
Super User

Re: Filtering records with current user

I have not used CRM at all, so I cannot answer that question; hopefully someone else can. There is one way to find out though - try it! It can't work less, right?! 🙂

vaishalivyas1
Level: Powered On

Re: Filtering records with current user

Hi @BitLord69

 

Thanks, I will try. 

 

Regards,

Vaishali

Community Support Team
Community Support Team

Re: Filtering records with current user

Hi @vaishalivyas1,

 

That depends on the entity which stores the user information. For example, if the user of Created-by field in the Time entries is stored in Accounts entity, then the formula should be in the format below:

SortByColumns(
Filter('Time Entries',
LookUp(Accounts,
accountid=_createdby_value,
emailaddress1)
=User().Email),
"msdyn_timeentryid",
If(SortDescending1, Descending, Ascending))

The accounts entity should be added into the data source before you try this formula.

Add a data connection in PowerApps

Filter, Search, and LookUp functions in PowerApps

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vaishalivyas1
Level: Powered On

Re: Filtering records with current user

Hi @v-micsh-msft

 

I have User entity which stores the User Information.I added User Data source also. So I wrote code like this:

 

SortByColumns(
         Filter('Expense Entries',
                LookUp(Users, systemuserid =_createdby_value, internalemailaddress) =User().Email),  "createdon",         If(SortDescending1, Descending, Ascending))

 

It is giving me Warning

Screenshot_26.png

Community Support Team
Community Support Team

Re: Filtering records with current user

That relates to Delegation.

https://powerapps.microsoft.com/en-us/tutorials/delegation-overview/

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,866)