Hello Community,
I need your help please!
I'm building an App that has multiple buttons where I want to filter the gallery
These are my buttons choices
I have managed to get the Approved button working by adding this formula UpdateContext({FilterByApproved:!FilterByApproved}) in the OnSelect Properties,
and in the gallery items properties I have this formula, Filter(LithuaniaLeaveRequest, 'Created By'.Email = User().Email, If(FilterByApproved = true, Status.Value = "Approved", Status.Value<>""))
When I try the same principle for the other buttons I don't seem to get the same result.
I would like to only show the items in the gallery if the following is true
Status Value =
Approved
Declined
Or contains Pending HR Approval Or contains Pending Manager Approval
Can anyone help me with a solution please.
Thank you in advance
Claire
Solved! Go to Solution.
@ClaireAllen Try this,
We'll use just one variable.
In the OnSelect of All: UpdateContext({varFilterBy:""})
In the OnSelect of Pending: UpdateContext({varFilterBy:"Pending"})
In the OnSelect of Approved: UpdateContext({varFilterBy:"Approved"})
In the OnSelect of Declined: UpdateContext({varFilterBy:"Declined"})
In the Items of the gallery put this code,
Filter(LithuaniaLeaveRequest, 'Created By'.Email = User().Email &&
Switch(varFilterBy,
"Pending", Status.Value = "Pending",
"Approved", Status.Value = "Approved",
"Declined", Status.Value = "Declined",
true)
)
Please remember to give a 👍 and accept the solution as it will help others in the future.
Are your four buttons mutually exclusive selections? If so, how about putting an If statement on the Items property:
If(FilterByApproved, // insert code to Filter by Approved status
,
FilterByDeclined, // insert code to Filter by Declined status
,
SearchByPending, // insert code to Search for Pending status
,
LithuaniaLeaveRequest // to show all as the default
)
instead of going through all this trouble. Create one SharePoint choice Colum named "State" give choice like
Pending,Approved,Decline
Instead of buttons. Provide a dropdown with those values. and you will be able to filter your gallery without any variable like
Filter(LithuaniaLeaveRequest,
'Created By'.Email = User().Email,
State.Value=Dropdown.Selected.Value || Dropdown.Selected.Value="All")
@ClaireAllen Try this,
We'll use just one variable.
In the OnSelect of All: UpdateContext({varFilterBy:""})
In the OnSelect of Pending: UpdateContext({varFilterBy:"Pending"})
In the OnSelect of Approved: UpdateContext({varFilterBy:"Approved"})
In the OnSelect of Declined: UpdateContext({varFilterBy:"Declined"})
In the Items of the gallery put this code,
Filter(LithuaniaLeaveRequest, 'Created By'.Email = User().Email &&
Switch(varFilterBy,
"Pending", Status.Value = "Pending",
"Approved", Status.Value = "Approved",
"Declined", Status.Value = "Declined",
true)
)
Please remember to give a 👍 and accept the solution as it will help others in the future.
Hello @zmansuri
Thank you for taking the time to come back to me
My Column is already a choice column, and I wanted to use buttons but looking at your option I see that this would also work.
Thank you
Claire
Hello @CNT
Thank you for taking the time to come back to me
I think this is what I was trying to achieve, with the UpdateContext, I just could not get it to work but now I can.
Kind regards
Claire
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |