cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Naresh
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
v-xida-msft
Community Support
Community Support

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

8 REPLIES 8
Appsessed
Frequent Visitor

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) 

v-xida-msft
Community Support
Community Support

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

Yla
Frequent Visitor

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!

@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!

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.

 

chaule
Frequent Visitor

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

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.

Powerplatform01
Post Patron
Post Patron

Hi

You can watch this video to resolve your issue 

https://youtu.be/bEVMhBW6vm0

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,552)