CMS Development

Made
Member

Comparing Contact property as string

Good day, all!

 

I am working on a filter for an email, that requires me to compare a contact property to another value.

 

For a Customer with lastvisited set to text value "1234567890" the following happens

 

Input:

{% set standard = '1234567890' %}

 

<h2>

  Data

</h2>

...{{contact.lastvisited}}...{{standard}}...

 

<h1>

  Test

</h1>

{% if lastvisited == standard %}

<p>

  Match

</p>

{% else %}

<p>

   Mismatch

</p>

{% endif %}

 

Output:

Data

...1234567890...1234567890...

Test

Mismatch

 

 

pprint gives me (String: 1234567890)

I have tried to cast it as a string and as an integer and it did not help

I have hashed it and takes the length og both values, which both proved that they are not the same, eventhough they look like it.

 

Figuring it was a wrapper, I have tried to see if contact.lastvisited contains my "standard" string, and it does not.

I have tried to modify the string by appending a fixed set of characteds and subsequently removed them again, before compairing the two. They still do not match.

 

I have been unable to find any help in the documentation, in this community (so far) or on slack.

 

Any hack, trick, idea or thought is appreciated!

Thank you for your time

Madeleine

4 Replies 4
a_funs
Contributor

Comparing Contact property as string

How is nobody fixing this basic stuff?????? Every day something like this. FML my company uses hubspot!

Jaycee_Lewis
Community Manager
Community Manager

Comparing Contact property as string

Hey, @Made 👋 Let's see if we can get the conversation going for you. @alyssamwilie @DanielSanchez @Bryantworks, do you have any experience here? Or thoughts on how @Made might think about approaching their roadblock?

 

Thank you very much! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
paul_zen
Participant

Comparing Contact property as string

I've found the "answer": https://community.hubspot.com/t5/CMS-Development/HubL-if-statement-for-custom-contact-properties/m-p...

TLDR: this won't work because it's broken not implemented.

 

The only option I see now is to make a workflow and put conditions in there (I assume it will not always be possible).

paul_zen
Participant

Comparing Contact property as string

I have a very similar issue:

{% if contact.country == "PL" %}pl{% else %}en-us{% endif %}

Even though contact has the "PL" value ({{contact.country}} renders "PL") the condition resolves to "en-us".

And it seems that the same issue was brought up here: https://community.hubspot.com/t5/CMS-Development/HubL-String-Comparison/m-p/571538 with no follow-up 😞