Forum Academy Marketplace Showcase Pricing Features

Search Filter in repeating group

Hi,

I am new to bubble. I am trying to setup a search button workflow to filter results in my repeating group. I want the users to select either a category, location or date, hit search and populate results in the repeating group. Right now, when I select any of the search criteria, all the results get populated. Any ideas?

Screenshot of my search screen.

Thanks,
Igor

1 Like

For anyone to answer your question you need to provide more information. I suggest screenshots of the conditionals or workflows you think should be applying the filters. The front end tells us nothing.

Here are the conditonals and workflows I have so far. Let me know if there is anything else I can attach.

this is in my design for repeating group.

Search button workflow
46%20PM

I’m afraid this is beyond my current knowledge of bubble. With these screenshots, I hope someone else will be in a better position to help. Good luck with it and sorry I couldn’t help.

Bumping this up again to see if anyone else can help @irotsenmar . I can’t spot the problem.

Probably time to get into the debugger and inspect the element to see what is going on. It will break everything down and allow you to see the values of your search constraints. First guess is that the values in the constraint are empty, because Bubble excludes empty values, which would result in all values being shown.

1 Like

I agree with @mebeingken. The way you’ve got it set up, you need to choose something for every one of your restraints.

I created an advanced search page where a user could optionally pick filters. In order to do that, I had to create a State on the page of a list of things (classes in your case). I filled it with every record, then did a series of searches with one parameter (only if that parameter wasn’t blank) and replaced the State value with an Intersects with … action. If you’re new, that’s going to sound complicated, but at least know that you’re not crazy - this isn’t easily done.

I guess since you have only three filters, you could create 7 different searches and run the one that matches which filters the user has picked (1, 2, 3, 1+2, 1+3, 2+3, 1+2+3).

Hope this helps!

Hi @kirk
thank you for your help. Can you please let me know more details on how to create 7 different searches? I ran the debugger and @mebeingken is right. The constraint is empty. I cant’t figure out how to point it to the right data source. how to do I set it up so it’s not empty? :slight_smile:

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,

  1. Set state ClassList to nothing (this may not be the first time they’ve clicked the button)
  2. 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).
  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
  4. Set state of ClassList to Search for Class where ClassDate < ToDate’s value intersect with ClassSearch’s ClassList, only when ToDate is not empty
  5. 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
  6. 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
  7. 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.

@kirk

Thank you for all your help! I followed all of your steps, however I don’t see intersect with
option in the dropdown. Maybe I missed a step somewhere? Screenshot is attached below.

I scrolled all the way down but I don’t see intersect with

Use it in the value where you’re setting your state

Value: Search for Classess: intersect with classsearch’s ClassList

@kirk

Thank you for all your help. I’ve created all the steps that you listed above. The search results are still way off. I am attaching workflow screenshots. I am not really sure where I messed up in the workflow. In total, I have 10 steps in the workflow.

22%20PM 44%20PM
31%20PM 17%20PM 28%20PM

07%20PM 46%20PM
49%20PM
35%20PM

No problem at all. This is a fun logic puzzle to work through. It looks like you’re using a combination of my methods which won’t work.

Let me first describe the logic.

  1. ‘Interesect with’ means take two list and keep whatever’s in both lists. If you ever ‘intersect with’ and one of your lists is empty, you’re going to get an empty list.
  2. Let’s avoid filling your ClassList with all classes. As I said, it’s not a good practice at all.

Here’s the order to do things:

  1. Clear the list
  2. For each constraint, only if the constraint is not empty: If the ClassList is empty, fill it with the answer from the constraint. If ClassList is not empty, intersect it with the answer from the constraint
  3. Send the ClassList to your Repeating Group.

Now go through your list again. You should be able to spot where your logic is going awry. It might also be worth your time to learn about the debugger and how to use the inspector.

Let me know how it goes!

1 Like

Hi Kirk -
It looks like the dates filter works ok for the most part, however category and location still don’t return any values. I ran the debugger and it seems that category constraint always returns empty value. I suspect that I did not set up a list of categorys and locations right. Bubble always asks to enter for list of texts. Second screenshot below.

36%20PM

Hi Igor

OK. So, I’m going to assume your list of categories on the left is not a Repeating group, but a manually built bunch of checkboxes.

Looks like you need another state, this time with a list of categories! Let’s call it CategoryList (original, I know). Before you do your other big ClassList comparison, you need to build this CategoryLIst.

Here’s the steps:

  1. Clear the CategoryList
  2. For each of the checkboxes, add the corresponding Category to CategoryList, if checked.

That’s it! Now you can use your CategoryList for your ClassList search. It’s up to you if you want to add a workflow to the end that adds all Categorys if none are selected.

Here’s what a workflow for #2 should look like:

Note that you’ll need to manually enter the “Name = [Type Category Name]” constraint. Note also that this time you’re using a “merged with” join. This says add it if it’s not there already.

Give it a shot and let me know how it goes!

K

2 Likes

Hi Kirk -

In your first step " 1. Clear the CategoryList" Where do I find this option in the workflow screen? It seems it’s only available for repeating groups. Thank you for all your help. :slight_smile:

Do I need to create another repeating group called CategoryList ?
53%20PM

Hey Igor

The same way you cleared the list in your other routine. Set it to nothing.

K

This topic was automatically closed after 70 days. New replies are no longer allowed.