Hi All,
I have a gallery which should filter based on the User logged in. When the user logged in, is a Project Manager or any people in the manager criteria it has to filter only their respective projects. I have a search text input box(search text) and a Combo box(cs dropdown) as filter boxes.
When the Project Manager logs in their respective projects is getting displayed. when the CS Combo box value is selected their respective projects is getting displayed. But I have a requirement where when the user logs in and select some other name in the CS combo box it must display all the projects with the selected person name. I tried with few possibilities but its not working.
The code on the Items gallery is :
Filter(
ProjectMaster_List,
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),
If(
Is Blank(SearchBoxShp.Text),
true,
SearchBoxShp.Text in ProjectName || SearchBoxShp.Text in DDName.DisplayName || SearchBoxShp.Text in DMName.DisplayName || SearchBoxShp.Text in 'Vertical Sales Head'.DisplayName || SearchBoxShp.Text in ProjectManager.DisplayName || SearchBoxShp.Text in Practice. Value || SearchBoxShp.Text in AccountName1
) && If(
Is Blank('CS Combo box'.Selected.Value),
true,
'CS Combo box'.Selected.Value in 'DelEx Consultant'. Value
)
)
I added another And condition and gave !Is Blank('CS Combo box'.Selected.Value) the gallery filtering and combo box is not working properly.
Any help/suggestions on this.
Thanks in advance.
(You second comment came in while I was typing, so I'll answer both here.)
So just to be clear.
If I log in, then I see my projects by default.
If you log in, then you see your projects by default.
But, If I want to see your projects, then I select your name from the combo and then what should I see ?
A. Both of our projects (varCurrentUser and also varDelegateuser) or
B. Only your projects (varDelgareuser only)
In the App On Start, you are setting varCurrentuser.
However, If you want filter by another user (for either A or B above) then it's probably best to set that in another variable, so that the varCurrentuser stays constant for the whole app.
So when the app starts, you may as well set varDelegate to be the same as varCurrentuser
So the filter should return only the varCurrentuser records before you select from the combobox.
Then when you select the other user from the combo, the OnChange event will update the varDelegate.
That way, this condition will look for both the varCurrentser AND the varDelgateuser.
To test, I would comment out the rest of the filter and only use this as a starting point.
Filter(
ProjectMaster_List,
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || (ProjectManager.DisplayName = varDelgateuser && ProjectStatus.Value = "Active"))
You will probably need to play with this concept a little to get it working correct.
Then when you know that the first part of the filter is working, add the rest of the filter conditions - piece by piece.
By the way - I think there is a problem with the following:
Filter(
ProjectMaster_List,
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),
If(
I think it should have a 'And' just before the 'If('
Filter(
ProjectMaster_List,
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active") And
If(
- like this
I guess it is working but as you told to Reset the Var Delegate. If the given the Reset function in the On change its giving an error.
Where should I give this both conditions On APP On start or Combo box On Change.
UpdateContext({varDelegate:User().FullName});
UpdateContext({varDelegate:[CS ComboBox].Selected.FullName});
I have given the Set variable on the App ON start. It must work as when user logged in is a PM their projects must display. When any one of the person from the CS Combo box logs in their projects must display. And when logged in user select any value from the Combo box it must display the Combo box selected value also.
I hope now you get an idea of the scenario.
I am assuming that varCurrentuser is being set when the app is opened.
I would consider creating a different variable so that you can change the 'user' for when you filter.
So when THE APP STARTS, add this just after you set varCurrentUser.
UpdateContext({varDelegate:User().FullName});
So now, in the on change event of the CS ComboBox, reset the varDelegate
UpdateContext({varDelegate:[CS ComboBox].Selected.FullName});
so that the filter will apply in the gallery as follows.
(ProjectManager.DisplayName = varDelegateuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varDelegateuser && ProjectStatus.Value = "Active"),
You will want to reset varDelegate back to the current user at some point.
If I give in the above way as you mentioned even the logged in user values is not filtering and listing certain different projects.
I think that you are only looking at the CURRENT user ?
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),
Try changing the above line to
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = CS ComboBox.Selected.Value && ProjectStatus.Value = "Active"),
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional