Display condition based on URL, Image, or any Complex module field?

Is there a way to put a display condition on a field based on the value of a url, image, or any other module field with a dictionary value?

For example, I’d like to show module fields if a URL field’s (named “my_url”)
href matches http://example.com

yo @John ,

You basically want the anti regex option. I am going on a limb and saying not possible, but I could be wrong

@tjoyce , @jpsanchez , @Anonymous what do you guys think about John’s dilemna?

Hey @dennisedson was there ever a solution to this? Do I really need to use a regex based on the output JSON just to check if a choice is selected in my Choice field?

I would love to just use something along the lines of “contains” i.e. if user has selected [“title”, “text”] out of my Choice field [“title”, “text”, “button”, “butter”] then I will display fields dependent on “title” and “text” respectively. Seems straight forward enough in a JavaScript way but not sure if HubSpot has something built in.

Yes, you can, but you would have to match the whole dictionary, you won’t be able to cherry pick values

Here’s an example URL condition

url_field
is equal to
{"type":"EXTERNAL","href":"#12345","content_id":null}

Here’s a video showing it working

@tjoycefor the win! That pointed me in the right direction.

How did you arrive at the order of type, href, content_id? Developer info? Whenever I pprint a url field in a module.html file, it has a different order (see code line below).

{"type":"EXTERNAL","content_id":null,"href":""}


I was concerned that HubSpot might swap the order one day, so I built a regex instead. Because the community has been so generous with information, I will include the regex below for anyone who comes across this in the future. Hopefully it will give you some inspiration :slightly_smiling_face:

url_field
custom regex
\{(("type":"(EXTERNAL|FILE)",?|"content_id":null,?|"href":"(.*(.mp4|.webm))",?)){3}\}

The regex looks for either a file or external url that has an href ending in “.mp4” or “.webm”.

Please note: if you are using local dev, you will have to escape the regex for json.

"controlling_value_regex" : "\\{((\"type\":\"(EXTERNAL|FILE)\",?|\"content_id\":null,?|\"href\":\"(.*(.mp4|.webm))\",?)){3}\\}"

Ahhh, nice elegant regex…

Yes, I opened the network tab to see what the dict looked like when it got pulled from the hubspot API. There was a lot of JSON in that network call so it was a little tedious to find but, the curiosity of answering the question got the better of me :grinning_face_with_smiling_eyes: