Repeating group filtering from a custom state's selection list

Hi there I have been struggling with this for a few days. In that journey I have realized there are numerous ways people filter search in bubble. Here is a video link for my particular conundrum.

I am looking to use items from a list saved to a custom state to filter a repeating group search. Is this possible? Or is there a better practice for this use case.

I have a page to input scripts with that I have used @gregoryjohn 's wonderful example to build a custom state to track which genre in a list of genre’s has been selected. I then successfully have been able to use a workflow in a button to save that list of genre’s to the database.

I am trying to use that similar principal to use the selected genre’s on a search page to dynamically filter the search results in a repeating group. I realize the custom state is creating a list so maybe it isn’t possible but I wondered if there was a way that the repeating group can recognize the text in the list and use it to filter the search?

Thank you in advance for any guidance you can give on this. It seems like it should be possible but I’m missing the logic somewhere. @boston85719 I think I’ve seen you addressing something like this but couldn’t follow in the other thread.

Jeremy

Please pick a subcategory to help organize the information. Thanks!

Also, the more context you provide with your questions (screenshots, link to an open app, etc.), the more likely you’ll get good help quickly :slight_smile:

I appreciate you taking the time I did come across that thread. This method uses a URL and a separate search page correct? I’m looking to do all of the filtering on one page without a button. I have found a work-around it does the job using the item’s in the list by list:item# I figure that there would be a max of 3 of each of those selects per group and any overlap would catch anything. All of the other dropdowns and search seem to work it was figuring out how to target the items selected in a custom state.

I will style and fill up the repeating group with more script details and see how it holds up under testing. I will have to go through the example though and wrap my head around the more complex applications . Thanks again.

1 Like

No the method uses the URL parameter, but it is on the same page. The reason URL parameters are better than a custom state is that if your user were to navigate away from the search page, the customs state values get lost, whereas the URL parameters remain in tact.

You can also save a search through a single text field by saving the URL, so a user can return to the same search filters in the future if you set that up.

Probably not going to be the best method unless you restrict the filter to only allow 3 choices, but why would you want to deliver a poorer user experience by limiting their filter abilities?

Thanks Boston I took your advice and reconstructed the genre list following your instructions and the result -
genres=thriller%2C%20family%2C%20historical%2C%20sci-fi%2C%20fantasy . So that is awesome I can repeat the process to change all of the option selectors, and dropdowns to URL parameters. But I think I’m missing a vital step because I don’t seem to understand how to get DATA from URL to filter my repeating group. It is not an option that is coming up for me when add constraints on a search. Initially it gives me the list of fields in my script data type. Then when I select genre gives me options pertaining to lists.

Here the data I am working with in the database. My data type of script

and my genre option set

Besides that, can you explain in plain English the workflow I copied from the Page load in your walkthrough. What do steps one through 4 accomplish? Thanks.

2 ways to solve:

  1. custom state lists and option set lists (no URL parameters)
  2. URL parameters (I have probably done a slight mashup of @boston85719 early and later techniques)

To save time recreated a piece of your database as follows:

Created 2 RG’s on page: 1 for filter, 1 for displaying results - note data types on each ie filter is using “option set list” and displaying results is using "script datatype from DB)

Let’s fo to filter first… have an icon and text in a group in the RG. Set states on these…

Then moving onto RG set which data to search based on what conditions your have in conditions. You can NOT filter a list where the list can bring multiple answers on the search side. You typically have to filter ie “do a search for:filter” and used an “advanced” expression.

In this case count=0 is saying there is nothing there, while count >0 is saying there is at least one filter chose. Notice also that sometimes you might want to ignore empty constraints - ie let people not fill out question. You can ignore or include constraints on your search as well as on your filters. As far as the filter itself you essentially need to compare the row in DB against the custom state list. In this example I am using “contains list” to force an "and type answer ie the RG would only show answers where all the checkbox apply. If you were going for an “or” answer you would use “intersects with”. So my expression is "Advanced = this “DB datatype” “data field” “contains list” “custom states element” “custom state”.

Moving onto URLs and parameters… much of course is the same - here are screen shots showing where the workflow is different. Essentially genre (key) = “custom states element”“custom state”“option sets attribute”. Easiest thing is to set this to “filter” per @boston85719 suggestion and make sure to use lower case and treat it like a slug. Slugs have to be lowercase to work.

Then on the RG itself the conditional filters change to account for the fact you are now comparing the DB to URL parameters instead of custom state list.

Hopefully that makes sense.

1 Like

Thank you so much for taking the time. The step I was missing in both cases was setting the conditional on the repeating group result. And thus the list filter expression needed. I was mistaken setting the ignore empty constraints was enough. What I’m unclear on with the conditionals why does the count matter? Is that what gives the ability to filter? I’ll have decide if there is benefit to having url parameters over the custom states. But having a clear option between the two is super helpful.

@jbleroux - In the URL example I didn’t need to have both when statements - ie both count equals and URL equals but wrote out both to show you options. The count in custom state examples was needed in the conditional for it to determine when to run each search. Think of it this way maybe - when count=0 essentially it means when nothing is checked and no choice is listed in the custom state list do search x (basic search showing everything because I am not filtering) and when the count>0 at least one thing has been checked and at least one choice is listed in the custom state do search z (which involves this additional info ie the filter).

I’ve discussed the benefit in the posts on the subject…URL parameters are not lost when a user navigates but custom states are, so a back button or forward button on the browser and the search filters are lost with custom states, URL parameters they are not…Also URL parameters will allow you to save a search as a single text field in the DB if your app requires that sort of thing.

There is no need for any numbers or conditionals on the search following the method I outline in the post on parameters as a list…if you focused on the first in the thread, it is outdated and unfortunately Bubble won’t allow edits to it, so looking further down at my last post in the thread to demonstrate an updated approach removing the need for any custom states.

Here are screen shots of how I have a search set up

Screen Shot 2021-03-25 at 10.25.57 PM

The conditional is only based on if they want to search the restaurants that are in their favorite list, so I put a conditional to grab their favorites list instead of the entire database of restaurants.

Thank you @boston85719 and @ccabaj both again. This is getting there and once I have a firm grasp how to repeat it maybe I can create a video that can help others in really simple terms as I feel this is a pretty fundamental aspect for searches. I have recorded a video of where I’m at and stuck following the directions laid out.

I think the first half or 3/4’s of the steps are fine. I can create the workflow to click the box which in turn sets the URL parameter and can see the results in the URL. I’m stuck at the repeating group search results. I have copied the steps laid out in the images from The RepeatingGroup Result from @ccabaj but I do not get the option to select a data source. I’m not sure where that comes from. image image I appreciate the notification about the update @boston85719 because I read the update as an add on not as a replacement for. It is unfortunate that bubble won’t let you edit the post because it probably would help simplify the process. For this run-through I am following @ccabaj 's instructions in this post for URL parameters to see if I can get it working before I switch up the methods. Is the List Shifter in the images above a plugin?

1 Like

Hi @jbleroux .

So if you are getting data from a data source you need a link to it. Option 1: 1 main data source on “first page of editor”. Second option as part of conditions like this… by clicking on “selecting on property to change when true” - and selecting data source. There you will need to do a search for - select script and click on the more button. This will bring you to filter where you can write advanced expression. You may need to play around with your when statement depending on what you have done as well as ignore or include constraints (by checking or not checking that box).

So far I have given you an option:
a: using states and option lists
b. using custom states and URL parameters (a mashup of @boston85719 earlier and later methods) so thought I’d better sort out a clean “no custom states” and URL parameter method (ie try to replicate @boston85719 later method). I may still have done it a tad differently …

Here are the screen shots using same database for third version:


Hopefully this doesn’t cause confusion but in this version I simply used only one data source (ie no conditions) - as I believe the Regex is taking care of a number of things (contains/doesn’t contain) and the URL instructs what I need. There would be other instances when you would want to use a conditional including a when and varying data sources.

1 Like

@ccabaj Thank you, thank you, thank you. I appreciate you taking all the time and I will be sure to pay it forward when I can. I have used the search for data source before and filtered the search with all the dropdowns but because I was following step by step I didn’t want to do anything to screw it up. It works and further-more I understand how it works. I’m sure the conditionals add more complexity if needed but simplicity is the name of the game with this app. Now I can go through and do this URL parameter method for all the filters. The URL parameters might even be overkill right now, but they will make scaling much easier in the future. Going through this process with you and @boston85719 has also helped me understand the way Bubble structures the statements better so hopefully I can figure out more of them in the future on my own. Thanks again.

2 Likes

@jbleroux - Great to hear!

1 Like

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