Now that Iâm looking at your screen closer, the âevery possible combinationâ method will be impractical. Especially since it looks like youâve got multiple selections allowed for Category and Location.
So, hereâs how I did it. Iâll assume you have a page called ClassSearch, a Repeating group called RGClasses a thing called Class and each Class has a ClassDate, Category, and Location.
The idea is to have a state on the page of a list of classes. Letâs call it ClassList. The default should be empty.
When Button is clicked,
- Set state ClassList to nothing (this may not be the first time theyâve clicked the button)
- Set state ClassList to Search for Class with no constraints (I know this is not a good idea, weâll re-visit this later - just go with it for now).
- Set state of ClassList to Search for Class where ClassDate > FromDateâs value intersect with ClassSearchâs ClassList, only when FromDate is not empty
- Set state of ClassList to Search for Class where ClassDate < ToDateâs value intersect with ClassSearchâs ClassList, only when ToDate is not empty
- Set state of ClassList to Search for Class where Category is in Category Selected List intersect with ClassSearchâs ClassList, only when Category Selected List:count is not 0
- Set state of ClassList to Search for Class where Location is in Location Selected List intersect with ClassSearchâs ClassList, only when Location Selected List:count is not 0
- Display List in RGClasses. Data Source = ClassSearchâs ClassList
Intersect with is the key here. You start with a big list, then narrow it down for each constraint selected.
The big issue here is with #2. It is not recommended. It could horribly increase the load time of your page to return all Classes. It will help if you return only future classes, but itâs still not recommended. The solution is to not start with all records, start it with one of your constraints. That means set the state of ClassList without the intersects with clause. The trouble here is, how do you know if the constraint youâre calculating is the first one thatâs not empty?
So for each check of your constraints, add another step that checks if ClassList is empty.
Letâs apply this to step 3:
3) Set state of ClassList to Search for Class where ClassDate > FromDateâs value intersect with ClassSearchâs ClassList, only when FromDate is not empty and ClassSearchâs ClassList:count is not 0
3.5) Set state of ClassList to Search for Class where ClassDate > FromDateâs value, only when FromDate is not empty and ClassSearchâs ClassList:count is 0
You can apply this to the rest of the steps. The nice thing about this is that you can add another search constraint by adding only two new steps to your workflow.
You might add to the end of the workflow before your Display List step just in case no constraints have been selected:
Set state of ClassList to Search for Class where ClassDate > Current date/time, only when ClassSearchâs ClassList:count is 0
Thatâs it! Thatâs the gist and should be enough to get you going.
Let me know how it goes!
K
ps: a couple of âgotchasâ to watch for:
- Be careful of your date constraints. Youâre going to want to do a day add and drop the hours and minutes. Once you try this, youâll probably see what I mean. There are other posts that answer the Date < Other date question.
- Iâm not sure you can have a list of checkboxes. By that I mean that you canât return a bunch of checkboxes as a list. Youâre probably going to have to create a couple more states for a list of Categorys and a List of Locations.