Setting custom state from URL parameter

Hi everyone -

I’ve got a custom state that evaluates to an option in an option set. I’d like to use a URL parameter when a page is loaded to set that state and display whatever the chosen option is in a dropdown.

It looks like I can do this if the parameter passed is the same attribute as is displayed in the drop down; but it’s not working if I choose a different attribute as the parameter (does that make sense?)

So, for example:
Option set: Locations
Option: Los Angeles, CA
Display (text): Los Angeles, CA
Text Param (text attribute): los-angeles-rentals

On the homepage, the user chooses Los Angeles, CA from a dropdown, which sends a parameter (L=options’ Text Param) to a listing page, resulting in

On the listings page, I have a custom state Location that evaluations to a Location option, and a dropdown that displays Location’s Option’s Display. The initial content is set to display page’s Location custom state.

I have a workflow to set the Location to Get L from page URL, but it’s not working.

I did get it to work by passing the same Display text all the way through the parameter ( angeles ca), but that doesn’t look as nice and isn’t as SEO friendly.

Is this just not possible if you’re using different attributes of the same option? Additionally, is there a way to do this simply through a path and not through a parameter?

Thanks for any help!

If you define the URL parameter type on the page (when using Get data from URL) as an option set, then the parameter value must be the option set’s display for the specific option to be selected correctly, as you’ve discovered.

The same applies to Path parameters.

The simple/obvious way to achieve what you want is just to change the Option set Displays to be the current text parameter value (swap the display and text attribute around in your option set).

But, if there’s a reason you don’t want to do that, then the other way is to filter the option sets based on the URL parameter.

So on page load run a workflow to set the custom state, use Get All Locations, then filter the options by the relevant attribute, using Get Data From URL to specify the option. As the result will be a list of options, you’ll need to add ‘First Item’ to select the specific option and set it as the custom state.


This is perfect, thank you so much! This solution didn’t even cross my mind

1 Like

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