cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Filtering a gallery by user

Hi frds,

 

I have created an app with the Sharepoint list.

The gallery displays the request of all the users. I need to filter like User can see only the requests created by him.

 

Please let me know how to filter the gallery.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Filtering a gallery by user

Hi @Naresh,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about your SP list?

 

I have made a test on my side, please take a try with the following workaround:1.JPG

 

Set the Items property of the Gallery control to following formula:

Filter('20180709_case4',Author.Email=User().Email)

Note: The '20180709_case4' represents the SP list data source within my app.

 

On your side, you should type the following formula:

Filter('YourSPListName',Author.Email=User().Email)

 

 

In addition, you could also take a try with the following workaround:

  • Set OnVisible property of the first screen of your app to following formula:
UpdateContext({CurrentUser:User().Email})
  • Set Items property of the Gallery control to following formula:
Filter('20180709_case4',Author.Email=CurrentUser)

 

More details about the User function, please check the following article:

User function

 

 

Best regards,

Kris

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

View solution in original post

7 REPLIES 7
Highlighted
Frequent Visitor

Re: Filtering a gallery by user

To acheive this, use a variable to get the users name either OnStart or OnVisible:

Set(ThisUser, User().FullName)

You will want this to match the SharePoint list - so if the request list stores the requestors name as an email, this must be User().Email, etc.

 

Set the Items of your gallery to:

Filter(SharePointList, RequestorColumnName.Text = ThisUser) 

Highlighted
Community Support
Community Support

Re: Filtering a gallery by user

Hi @Naresh,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about your SP list?

 

I have made a test on my side, please take a try with the following workaround:1.JPG

 

Set the Items property of the Gallery control to following formula:

Filter('20180709_case4',Author.Email=User().Email)

Note: The '20180709_case4' represents the SP list data source within my app.

 

On your side, you should type the following formula:

Filter('YourSPListName',Author.Email=User().Email)

 

 

In addition, you could also take a try with the following workaround:

  • Set OnVisible property of the first screen of your app to following formula:
UpdateContext({CurrentUser:User().Email})
  • Set Items property of the Gallery control to following formula:
Filter('20180709_case4',Author.Email=CurrentUser)

 

More details about the User function, please check the following article:

User function

 

 

Best regards,

Kris

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

View solution in original post

Highlighted
Frequent Visitor

Re: Filtering a gallery by user

Hello, I have similar requirement. I need to be able to filter the gallery base on the current user, the gallery is connected to the database that has the list of all the employees from two different branch office. Each branch office has an HR. So, if HR 1 is log in i want the gallery to show only the employees from Branch 1, same with HR 2 with only the list of employees showing from Branch 2. I've added an Office ID for each employee on the database. I also have a search box on top of the gallery. Right now, this the formula that i have, it works but it doesn't filter the gallery base on HR log in.

If(IsBlank(Search.Text),EmpCollection,SortByColumns(Search(EmpCollection,Search.Text,"LastName")"FirstName"))

 

Any tip would be great, Thank you!

Highlighted
Helper II
Helper II

Re: Filtering a gallery by user

@v-xida-msft 

What would be a solution to delegation for that formula? Is it possible to only show the last 5, 10, or 15 items created for that user?

My concern is the list I am creating will supply list of requisitions for tools submitted by users, the list will become very large, very quickly. I don't want the app to  be slow because of it.

Any assistance would greatly be appreciated!

Highlighted
Helper I
Helper I

Re: Filtering a gallery by user

Hello,

 

I tried the suggested formulas:

  • Set OnVisible property of the first screen of your app to following formula:
UpdateContext({CurrentUser:User().Email})

This is not work at all, I was not able to filter out other submissions and only view the user submissions.

 

  • Set Items property of the Gallery control to following formula:
Filter('20180709_case4',Author.Email=CurrentUser)

This is did work, however it created an issue alert. I attached the alert message, but it says it doesnt work on large data sets.

 

Highlighted
Frequent Visitor

Re: Filtering a gallery by user

Author.Email seem to not work for me.  Anyone know why that may be?

Highlighted
Resolver I
Resolver I

Re: Filtering a gallery by user

Hi @chaule ,

Were you using @v-xida-msft 's workaround? Do you have a multi-screen app, where your gallery/data table that you are trying to filter is not on the first screen? If yes...

I tried the workaround too and also couldn't get it to work. But then in this part:

"

  • Set OnVisible property of the first screen of your app to following formula:
UpdateContext({CurrentUser:User().Email})

"

I set the OnVisible property not on the first screen of my app, but the screen where the gallery/data table is, and it worked. 'UpdateContext' only works on the screen it's attached too. (from https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-updatecontext)

I hope that helps.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,207)