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

Filter gallery to only show record for current user - SP list

Hi, I have been on numerous forums & watched a number of videos but still struggling! I have an app which is linked to a SharePoint list with over 1400 employees. I have developed the app based on the 'out of the box' phone layout template that comes already set up with various functions & pages.
My query is how do I filter the gallery to only show the record for the current user? I am aware there could b delegation issues due to the size of the SP list.
The code which was already populated in BrowseGallery1 – Items = SortByColumns(Filter([@'OE Asset Register - Staff Data'], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Filter gallery to only show record for current user - SP list

Hi @Flockters 

 

To configure this, you can follow:
 
1) Set a variable to get the current user details:
App -> OnStart -> Set(MyDetails, User())
 
Note: If you are in edit mode, select the three dots on the left menu and select "Run OnStart". This will populate the value for current session and this variable will automatically set when the app is played or refreshed.
 
2) Update the expression on the gallery control Items to:
SortByColumns(Filter([@'OE Asset Register - Staff Data'],ColumntoSearch = MyDetails.FullName && StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
 
Here I assumed that you have a single line of text column which stores the name of the users. 
 
If this a person type column:
SortByColumns(Filter([@'OE Asset Register - Staff Data'],ColumntoSearch.DisplayName = MyDetails.FullName && StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
Dual Super User
Dual Super User

Re: Filter gallery to only show record for current user - SP list

Hi @Flockters 

 

To configure this, you can follow:
 
1) Set a variable to get the current user details:
App -> OnStart -> Set(MyDetails, User())
 
Note: If you are in edit mode, select the three dots on the left menu and select "Run OnStart". This will populate the value for current session and this variable will automatically set when the app is played or refreshed.
 
2) Update the expression on the gallery control Items to:
SortByColumns(Filter([@'OE Asset Register - Staff Data'],ColumntoSearch = MyDetails.FullName && StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
 
Here I assumed that you have a single line of text column which stores the name of the users. 
 
If this a person type column:
SortByColumns(Filter([@'OE Asset Register - Staff Data'],ColumntoSearch.DisplayName = MyDetails.FullName && StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

dynamicsedge
Level 8

Re: Filter gallery to only show record for current user - SP list

@Flockters 

Consider leveraging User() to help you here. This is an out of the box PowerApps function that returns useful contextual information about the current user that is using the app. If any of the below is in common with one your columns, you can try and filter by this information and it is a handy way to use the current user's contextual info - including even to possibly filter your SharePoint List by this information.

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Returns information about the current user.

Description

The User function returns a record of information about the current user:

Property Description
User().EmailEmail address of the current user.
User().FullNameFull name of the current user, including first and last names.
User().ImageImage of the current user. This will be an image URL of the form "blob:identifier". Set the Image property of the Image control to this value to display the image in the app.

 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,431)