cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

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 II
Dual Super User II

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 II
Dual Super User II

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

Super User II
Super User II

@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
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (2,496)