Issue with a Custom State to a Filter RG

Good morning fellow Bubblers!

I’m developing a brand directory allowing people to find ethical and sustainable brands. The index has one main repeating group and a bunch of filters (category, subcategories, targets, price range, ethical level, etc.)
Yesterday, I tackled the custom states implementation on the “Category Filter” and “Ethical Level” to let users multi-select them and get more granular results.

It worked as intended on the “Ethical Level” because a brand has only one level of ethic.
But because a brand may have multiple categories (list) assigned to it (which is the main difference), I can’t make the result appear on the RG.

Here is a screenshot showing the issue. It works only if I add :random at the end, but it messes the results…

I would be very glad to find help to fix this.
Thanks a lot in advance for your time!

I guess that your “Index’s Category” is a list and with Contains, Bubble expect unique value. It will work with random, first item, item #… If user can only select 1 category, change the state to be a single value, only a list. If you want to use a list of category, you may consider intersect or advanced filtering

Can you tell me more about advanced filtering in the case of letting people interact with multiple categories?

When you Get data (using Do a search for example), directly in the Do a search, you cannot compare a list with another. It’s actually a limitation on Bubble side. The only way to do it is to, after the “Search for Brands” click “more” and select :filtered. In Filtering, you have a function Called “Advanced”. This is where you can enter more complex request and, in your case, you will be able to compare two list.

It will probably look like This Brands’s category intersect with Category State list: count > 0

I feel dumb, but I cannot see the “Advanced” setting when :filtered is applied after “Search for Brands”.

Click + Add a new constraint

Capture d’écran 2021-01-21 à 09.55.30

It’s done. Now the results are “empty”.

Check in debug mode to see what is returned on each step.
Also, you may need to have a condition that will manipulate the list according to state. If state is empty or not. (Empty, you should remove the filtered)

I see. First, here is the log on the debug mode, maybe you’ll notice something in it.

Click on “Search for Brand:filtered”
At the right, you will be able to click on each section of the expression and this will show you the results or each part and the final result too

I’m learning things everyday, I love it! Thanks for the “debug mode tip”.
Here are the screenshots of both parts of the expression. I don’t really know what I should be looking for.

Did you click on “empty” in advanced?

Sorry for the delay Jici, I’m now back in front of the computer.
So I figured out that it displays properly the results only when at least one of the category filters is pressed, even if “Ignore empty constraints” is checked in both “brand contraints” and “:filtered constraints”.

So, I put a conditional directly on the “brand’s repeating group” saying that if the custom state is < 1 then change data source to “Search for Brands”. And now it works smoothly.

Thanks a lot for your help, it was really appreciated.
Hoping this thread is going to be helpful for other people as well!

1 Like

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