Skip to main content

I want to write a section of my email to display a sentence based on the value of a custom property.

Here’s an example:

The value of Grown Tomatoes Before? is: 

{% if person|lookup:'Grown Tomatoes Before?' == 'Yes' %}

Yes, they have.

{% elsif person|lookup:'Grown Tomatoes Before?' == 'No' %}

No, they have not.

{% else %}

Unknown value.

{% endif %

 

But, this doesn’t seem to work.

Hi RedPhive

It seems like you're encountering an issue with your email template logic. I'd be happy to help you troubleshoot this! Please reach out to me directly on WhatsApp at [+234 9151237531], and we can work through this together.

Looking forward to assisting you!


It looks like you're on the right track with using Liquid syntax for your email, but there’s a small syntax error in your code. The closing tag for the endif statement should be {% endif %} instead of {% endif %. Here’s the corrected version:

 

liquid

Copy

The value of Grown Tomatoes Before? is: {% if person|lookup:'Grown Tomatoes Before?' == 'Yes' %} Yes, they have. {% elsif person|lookup:'Grown Tomatoes Before?' == 'No' %} No, they have not. {% else %} Unknown value. {% endif %}

Explanation:

  • Correct Syntax: Make sure to use {% endif %} to properly close your conditional statement.
  • Lookup Function: Ensure that the custom property name is spelled correctly and matches exactly what is in your database.

Additional Tips:

  • Testing: Always test your email with sample data to ensure that the conditions are working as expected.
  • Debugging: If it still doesn’t work, check if the custom property is set correctly in your database for the contacts you are testing.

Feel free to reach out if you need further assistance!

Best Regard

Mic pro


That missing curly bracket was a typo.

The code still doesn’t work correctly.


Hello RedPhive,

It seems like you're trying to display different text based on the value of a custom property in your email. The issue might be with the syntax. Here’s a more streamlined approach:

 

liquid

Copy code

{% if person.Grown_Tomatoes_Before == 'Yes' %} Yes, they have. {% elsif person.Grown_Tomatoes_Before == 'No' %} No, they have not. {% else %} Unknown value. {% endif %}

Ensure the property name is exactly as defined in your system, and check for any syntax issues with your variables.

If you still need help or have other questions, feel free to reach out to me on WhatsApp at a+234 9023453575]. I'd be happy to assist!


Reply