cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
darrenfloyd666
Post Prodigy
Post Prodigy

Filter gallery based on user login

Morning

 

I want a user to see the holidays they've taken and what's remaining when they visit a page.

 

I've tried 'Filter(Abscence_Request, Staff_member=User.email()),' but I'm getting errors. Where am I going wrong? All help appreciated!

 

Absence_REsults.png

1 ACCEPTED SOLUTION

Accepted Solutions

@darrenfloyd666 ,

No - the screen that this is contained in on the OnVisible property.

ScreenOnVisible.png

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

12 REPLIES 12
WarrenBelz
Super User III
Super User III

Hi @darrenfloyd666 ,

Firstly looking at your gallery, I think you need User().FullName. Also this is not Delegable, so do this - at App OnStart

Set(vUserName:User().FullName)

Then your gallery

Filter(
   Abscence_Request, 
   Staff_member=vUserName
)

What are the errors you are getting? Is Staff_member a Plain Text field, or a Choice or Lookup field.

If a Choice field

Filter(
   Abscence_Request, 
   Staff_member.Value=vUserName
)

If a Lookup, this requires a different approach.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

Hi @WarrenBelz 

 

Thanks for the reply.

 

Yes the Staff_member field is a Look Up.

 

I tried using the formula Filter(
   Abscence_Request,
   Staff_member=vUserName
)

 

and got the error 'Invalid Argument Type'

HI @darrenfloyd666 ,

I suspected as much. I will make two suggestions

  1. If you want to have effective data management in PowerApps and don't ever want users to do bulk edits in SharePoint datasheet views, throw them away and forget about them forever as they are of absolutely no use to you. All the Lookups can be done in the PowerApps Items of the drop-downs and simply write back to plain text fields
  2. If you really need to use them, filtering on them is highly problematic as you have found, Lookup fields are complex field types (they are actually tables) and have two parts Value and Id. These actually refer to the list they are based on (not the target list) and you need the Id part.  A better approach would be to have a "dummy" text field (you can hide it) updated each time the staff member field is changed and then filter on this.

Hi @WarrenBelz 

 

Yeah I need to stick with the Look Ups. So with the dummy text field with the staff member what would be the best way to update that. Off the top of my head I'm thinking a Flow?

Thanks @darrenfloyd666 ,

No a lot easier than that. Have the field DataCard with a Text Control hidden on your form - I tend to use Variables as below as they always work - call it whatever you want.

On the OnChange of your drop-down

UpdateContext({vStaff:YourDropDownControlName.Selected.Value});
Reset(YourHiddenTextControlName)

And the Default of your Text Control

If(
   !IsBlank(vStaff),
   vStaff,
   Parent.Default
)

A bit of a tidy up - Screen OnVisible

UpdateContext({vStaff:Blank())

You then have a plain Text field for any Filter, Lookup or Sort that is completely Delegable.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Hi @darrenfloyd666 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks @WarrenBelz just rolling back to this. Where does the: 

A bit of a tidy up - Screen OnVisible

UpdateContext({vStaff:Blank())

 go?

@darrenfloyd666 ,

Exactly there - on the Screen property OnVisible. (open the screen and it is in the drop-down at top left).

Just makes sure the variable is reset when you enter the screen.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelzOh, on the hidden text control?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (18,300)