Get List from URL Parameter (List of Unique ID and Text)

Here’s how to get a list of things from the URL parameter. Link to editor below.

Getting one item from URL is easy. Getting a list of things from URL is harder, especially when it’s a unique id vs. text.

Once I figured it out, it’s pretty straight forward.

Link to the demo and editor

PRO TIP: by default bubble passes list of text delimited by a comma then a space , . They don’t do it by default on a list of uniqueIDs (things). To keep things standard it’s best to set your own rules of a comma followed by a space to delimit uniqueID

I’ve seen post about getting a list of options from URL, and an array of things from URL. Thought this would help. Option sets work the same as text described above.

1 Like

Instead of format as text, you can also just use… :join with :wink:

1 Like

@brad.h I think “Unique ID is in” is new functionality. In the past it was only = or <>. Now that we can use “contains” logic, this becomes a lot more straightforward! Thanks for sharing.

2 Likes

thanks! join with is not an option here. merge with?

No. Join with.
In your case: This multidropdown’s value’s unique id:join with ,

1 Like

Bubble doesn’t officially support a list of Things in the URL parameter :frowning_face:. I’m wondering if I should revert back to custom states before going too far down this path.

I asked bubble support “why”. I’ll update this thread when I know more.

Yes you probably should not use URL parameters for a List UNLESS the max count of the list is ~3ish AND the filters for the list have a high WU consumption.

1 Like

I plan on 10 or 20 max :face_with_peeking_eye:

I have a RG that users can search and filter. For a lot of reasons, I want to use URL params instead of custom states.

@code-escapee, are you pretty confident that I should use custom states…not URL params?

@sharma.himanshu0608 posted this article…I’m doing something similar.

It’s hard to say without understanding what the most pressing of the reasons are but unless you’re are sadomasochist (not that there’s anything wrong with it!) you most likely don’t want to use URL parameters.

Custom states are not the only option, but it all depends on the use case and your motivations: point_up:

1 Like

Thanks :pray:! What’s the reason for 3 max?

there is a limit to URL length based on different browsers…but it’s actually a lot of text.

I’m happy I’m an aware of all this, only since you mentioned.

The headache of troubleshooting the parsing of a longer string and the performance involved in parsing and then intersecting a RG.

Gotcha! You’d still need to parse and intersect a custom state tho.

Either way…I think I’m backing out of URL Params in favor of states .

Absolutely not!

Again, without knowing any reasons or use case, the primary reasons to consider URL parameters are for page navigation or refresh.

I suppose the benefit of search filters that pulls from the url (which incidentally what amazon, airbnb do etc) is that if you forward a url address it will pass on the saved searched filters - something that you could not achieve with custom states.

This airbnb url represents a filtered search with a list of property types included in the search

https://www.airbnb.co.uk/?tab_id=home_tab&refinement_paths[]=%2Fhomes&search_mode=flex_destinations_search&flexible_trip_lengths[]=one_week&location_search=MIN_MAP_BOUNDS&monthly_start_date=2024-01-01&monthly_length=3&category_tag=Tag%3A7769&price_filter_input_type=2&channel=EXPLORE&room_types[]=Entire%20home%2Fapt&search_type=filter_change&min_bedrooms=3&min_beds=4&min_bathrooms=5&l2_property_type_ids[]=1&l2_property_type_ids[]=3&l2_property_type_ids[]=2&l2_property_type_ids[]=4

Exactly. My use case is an email with a link to the filtered results. I ended up not going this route since bubble does not support list of things in the URL.

did you check out this post - I’ve tried it and it seems to accomplish the goal of getting lists in the url parameters

Whether its working around bubble’s documentation is another matter but it seems to work

That doesn’t mean you can not set up your URL parameters to be a list of things and work with it properly. All it means is Bubble doesn’t have a feature to make it easy ‘out of the box’, which is why I had to post the tip linked above in 2020. It works just fine with no issues.

Once it is setup properly there are no more aches or pains if you set 3 or 20 items in the list.

This is partly why I set out in 2020 to get this functionality to work. I also used it for saved searches and to make the UX awesome, so when a user clicks onto a search result and then navigates to the ‘product’ page, afterwards, if they use their browser back button, they are back on the search page with all their filters still selected (something most every single user of an app would expect)

Another reason for this is because custom states are temporary, so once your user refreshes the page they are all lost, whereas the URL parameters are still there.

It is not. It is just a solution to a problem that Bubble doesn’t provide an easy to use native solution. It uses all Bubble native features and is in no way (as far as I know at the moment) of being deprecated because of some change Bubble makes, as it doesn’t do anything to ‘trick’ the system.

2 Likes

@boston85719 thanks for the added color. I’ve been using your method and I appreciates the detailed post when I was setting it up :slight_smile:

1 Like

I got it working, this post is a “TIPS” category. I was sharing with everyone how I did it.

Shared the editor and demo link too.

I’m trying to optimize for reliability and minimal maintenance. I’m probably too conservative…but when I saw bubble does “not officially support” I ended up abandoning. But still wanted to share the tip with everyone.

Bubble added “Unique ID is in” to expression since 2020. Which makes it really easy with bubble out of the box. Check it out below :point_down:

and I totally agree with the below comment.