CMS Development

PKemps
Contributor

If statement on contact-property CMS

SOLVE

Hi,

 

I'm creating a custom form-module and wants to show form A when the custom "Business Unit newsletter" property contains Business Unit A. When the property is empty or only filled with Business Unit B or C, then show form B (else-statement).

 

The "Business Unit newsletter" property is a multi-select with 3 values of Business Units.

 

So i started the if statement with:

{% if contact.newsletter_business_unit.value == 'BU-A' %}

But this does not work.

 

Also tried:

- {% if contact.newsletter_business_unit is containing 'BU-A' %} => does not work

- {% if contact.newsletter_business_unit %} => if any value is filled, the right form (form A) is displayed, otherwise form B.

- {{ if contact.newsletter_business_unit.value|pprint }} => NULL

 

Can somebody see what i'm doing wrong?

0 Upvotes
1 Accepted solution
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

If statement on contact-property CMS

SOLVE

@PKemps got it, yeah i've run into that same issue before and did exactly what you've done with the delay. 
So i think you don't need .value in your if statement, i think it should look something like this. I test this with a test dropdown and it seemed to work

 

{% if contact.newsletter_business_unit == "Replace with Property Label" %}

Form Embed goes here

{% endif %}






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution

View solution in original post

4 Replies 4
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

If statement on contact-property CMS

SOLVE

Hi @PKemps, you might be able to create a few smart rules to display the form based on the logic. Create a few lists that meet the filter criteria of the business unit newsletter property and then display the specific form in the rules.

Also I'm not 100% sure how the contact value if statment works but what you have written should technically work. Maybe double check the value matches the internal value and not the selector value. 






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
PKemps
Contributor

If statement on contact-property CMS

SOLVE

I first worked with smart modules, but the "smart" is not fast enough to show the correct form. In the footer of our website (alfen.com) is a registration form and it asks which Business Unit you want to receive newsletters from. Based on that property, a form is used on the thank you page and the smart module does not work then because the contact is not yet in the correct list. The second i tried was to delay the thank you page to display but that is not a elegant and user-friendly way. So i trying to do this with a HubL if-statement. 

0 Upvotes
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

If statement on contact-property CMS

SOLVE

@PKemps got it, yeah i've run into that same issue before and did exactly what you've done with the delay. 
So i think you don't need .value in your if statement, i think it should look something like this. I test this with a test dropdown and it seemed to work

 

{% if contact.newsletter_business_unit == "Replace with Property Label" %}

Form Embed goes here

{% endif %}






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
Jaycee_Lewis
Community Manager
Community Manager

If statement on contact-property CMS

SOLVE

Hi, @PKemps 👋 Thanks for the question. Hey, @jonchim @jpsanchez, do you have any insight or experience you can share with, @PKemps? Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes