Using HubL filters and functions on custom properties

Hello everyone!

Hoping to be able to pull from someones experiance to help overcome a challenge we are facing.

We have created an HTML&HubL document to use as an email template to create notices to our exitsing customers of coming service changes. This will require several custom contact properties I have created, and some significant manipulation of those properties.

Here is a simple example that should, but does not work:

{% set new_day = contact.new_delivery_day%} <!-- Custom property of Single line text type, the contact I am testing with has the value “Thursday”-->

<p>New Day:{{new_day|lower}}</p> <!-- prints “Thursday” instead of expected “thursday” -->

The following works as expected:

<p>lower test: {{ “THURSDAY”|lower }}</p> <!-- prints “thursday” -->

Our suspision is that HubL is not treating the values of these properies as strings but some other datatype, so we also tried first applying the string filter:

{% set new_day = contact.new_delivery_day|string%}

But this did not change the results.

Any assistance you can offer will be greatly appreciated!

Hi @joesLost

Thanks for sharing the example — this is a great one to sanity-check, and I can see why it’s blocking you if you need to manipulate a lot of custom properties.

I’ll invite a few Community members who are very strong with HubL + custom property behavior to weigh in.
@HubDoPete @frameofwork @MichaelMa — have you seen cases where HubL filters like |lower work on literals but don’t apply to custom contact property values (single-line text)? Any known typing/encoding quirks or best-practice way to force a plain string so filters apply correctly?

Appreciate any insight you can share.

Best, Victor

If you’re able to test, I would suggest doing some pprints to see what HubSpot is currently holding:

Eg,

{{ contact.new_delivery_day|pprint }}
{{ new_day|pprint }}

This will dump out the data include the type. Eg, {{ year|pprint }} would return (Integer: 2026).

I recall having similar issues with some filters wherein the type is not what HubSpot expects which causes the filter to be skipped/ignored(?). Although I believe that was more for number or date filters.

Hi @joesLost,

According to the documentation, HubL filters are not supported in email templates when using them with personalization tokens.

@Victor_Becerra @MichaelMa @evaldas Thank you allfor the quick replys!

I ran a quick test as Michael suggested and I fear this confirms evaldas’ assertion that filters will not work for this application :pensive_face:

code:

<p>contact.new_delivery_day:{{contact.new_delivery_day|pprint}}</p>
<p>contact.new_delivery_day:{{contact.new_delivery_day|lower}}</p>
<p>New Day:{{new_day|pprint}}</p>
<p>New Day:{{new_day|lower}}</p>

Result:

contact.new_delivery_day:(String: Thursday)

contact.new_delivery_day:Thursday

New Day:(String: Thursday)

New Day:Thursday