Option Sets :converted to list - Get List of Options from URL

Question: how to extract Option Set as a list? I would assume the :converted to list function would do so, just like the extract with regex does for text values. However, it doesn’t.

__

Use-case: A user is searching for places to stay that has certain facilities. I am sending the search parameters to the URL, so the link can be shared with others. I now want to get the facilities from the URL and use them to compare whether a Listing has these facilities.

I have succeeded in doing this by comparing text value to text value, but it seems to slow down performance significantly. Thus, I would like to compare it as OptionSet instead.

Setup:
My Option Set is defined like this:

I have a data type called Listing which has the following setup:
image

I am sending the OptionSet values as search parameters to my url. Url ooks like this: /version-test/test?facility=Toilet%20Water

The problem is to Get the values from the URL. It works fine when getting it as text, but getting it as optionFacility is a problem, once there are more values than one.

Setup extract as type “text”
image

Setup extract as type “OptionFacility”

EXAMPLE 1: ONE VALUE
It works fine when there is one facility: /version-test/test?facility=Toilet
image

EXAMPLE 2: TWO VALUES
But fails when there is two or more values, it cannot get as OptionFacility: /version-test/test?facility=Toilet%20Water

image

__

So… how to extract Option Set as a list? I would assume the :converted to list function would do so, just like the extract with regex does for text values.

Any help would be greatly appreciated. Been stuck on this for a while now!

URL parameters aren’t really designed for lists, unfortunately. This problem isn’t exclusive to option sets, it exists for any complex type. For instance, you’ll have the same problem with User types instead of OptionFacilities. What it comes down to is that its difficult to construct a list of objects from a concatenated list of texts.

:converted to list also doesn’t do what you think it does. It takes a single instance of a type (text, option set, data, etc…) and turns it into a list containing only that item, so that you can append other data to it or store it in fields that are lists.

A couple workarounds:

  1. Do your searching directly rather than using the url paramaters unless the page is loaded for the first time. This will allow searching to be done quickly most of the time, unless the link is shared, at which point it will be done as part of the page load, which is more acceptable in the user’s eyes.
  2. Create a Search data item which has a field containing the list of options you want, then pass that data item as the page’s thing or as a url parameter.

Hope this helps


Getting stuck with your bubble app? Reach out to us at protomakr.bubbleapps.io

Try to follow the tip exactly as presented…it is made to show how to take an option set and use it as a parameter turned into a list and how to extract those values back out as the option set.

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