cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kasfour
Helper III
Helper III

Remove items in a gallery based on the logging user

I would like to remove items in BrowseGallery, based on the logging user. I tried in Visible, but the shown items are totally scattered, and when you press in the location of the hidden item, the data already opens as if it's there. Please help.

kasfour_0-1653958826618.png

 

9 REPLIES 9
EddieE
Super User
Super User

@kasfour 

You'll need to use Filter in the Items property. You'll need a field (or fields) that can be associated with the user somehow then Filter on that. If you share this field name and the Items property of your gallery I could help further

HYG, I already have a complicated filter in the BrowseGalley - Item property, for searching and sorting

kasfour_0-1653959707465.png

 

@EddieE , let me know if you need more details. Thank you.

@kasfour 

I need to see the Item property of the gallery to be able to help.

 

Seems you wish to filter on Name of person, is that correct? If so, do you capture this at App OnStart, like this?

Set(vUserName, User().FullName);

 

Have nothing on the OnStart. 

The Item property for searching and sorting is as follows:

 

SortByColumns(
Filter(
[@'WFH-List'],
Or(
StartsWith( 'Employee Name', TextSearchBox1.Text ),
StartsWith( 'Created By'.DisplayName, TextSearchBox1.Text)
),
Or(
'HR Request Status'.Value = HRdrpdwn.Selected.Value,
IsBlank(HRdrpdwn.Selected.Value)
),
Or(
'IT Status'.Value=ITdrpdwn.Selected.Value,
IsBlank(ITdrpdwn.Selected.Value)
)
),
"ID",
Descending
)

Ok, thanks.

 

And lastly, which field in your data source do you want to filter on?? For example, if you used my App OnStart code to get the logged in User FullName, you could do this

SortByColumns(
	Filter(
		[@'WFH-List'],
		Or(
			StartsWith( 'Employee Name', TextSearchBox1.Text ),
			StartsWith( 'Created By'.DisplayName, TextSearchBox1.Text)
		),
		Or(
			'HR Request Status'.Value = HRdrpdwn.Selected.Value,
			IsBlank(HRdrpdwn.Selected.Value)
		),
		Or(
			'IT Status'.Value=ITdrpdwn.Selected.Value,
			IsBlank(ITdrpdwn.Selected.Value)
		) &&
		'Created by' = vUserName
	),
	"ID",
	Descending
)

 

 

I need to remove the data based on 2 conditions. The logged user, and if user is in a certain ShP list. Below is the formula I used for the Visible property for the datacards. 

User().Email = ThisItem.'Created By'.Email || LookUp(

    'WFH-Approvers',

    Approvers.DisplayName = User().FullName,

    true

)

@kasfour 

You could try this

SortByColumns(
	Filter(
		[@'WFH-List'],
		Or(
			StartsWith( 'Employee Name', TextSearchBox1.Text ),
			StartsWith( 'Created By'.DisplayName, TextSearchBox1.Text)
		),
		Or(
			'HR Request Status'.Value = HRdrpdwn.Selected.Value,
			IsBlank(HRdrpdwn.Selected.Value)
		),
		Or(
			'IT Status'.Value=ITdrpdwn.Selected.Value,
			IsBlank(ITdrpdwn.Selected.Value)
		),
		Or(
			'Created By'.Email = User().Email, 
			User().FullName in Approvers.DisplayName     // <-- Delegation warning here from using 'in'
		)
	),
	"ID",
	Descending
)

 

There will be a delegation warning so not sure if that suits your needs?

kasfour
Helper III
Helper III

Thank you for your reply @EddieE . However, I do not need to add a new filtering condition at all. 

I need to have the browse gallery only show the forms created by the logged user upon start, and to remove (not hide) any other forms in the Gallery.

 

I tried the visible property, but it only hides while leaving the shown data scattered as shown below. this is whyi am aiming to remove the items at all when a user is logged and only show his created forms. Is there a way to do so >

 

kasfour_0-1654263409512.png

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,310)