CMS Development

hwkkelley
Participant

If statement based on a contact property checkbox being true

We have a contact property that is a checkbox. I'm trying to use an if statement to display certain content if the contact property is checked. I've tried all kinds of things and can't seem to get anything to work. I'm admittedly not a heavy programmer, but our normal developer left, so I'm on my own. 

 

You CAN make if statements based on contact properties can't you? I've seen it isn't supported in email, but as far as I can tell it is supported on pages. 

 

I tried {% if contact.myproperty.value is truthy %}

 

I've also tried {% if contact.myproperty %}

 

Neither seem to work. I'm also amenable to using a dropdown or even text field, as long as I can get the basic premise to work. The user won't be completing a form on this page or anything, I'm hoping it will display just based on whatever data we already have for that user. 

 

Thoughts? 

0 Upvotes
1 Reply 1
alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

If statement based on a contact property checkbox being true

Single checkbox properties use Yes/No values instead of being true or false. So you'll actually want :

 

{% if contact.myproperty == "Yes" %}

{% endif %}

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.