Skip to main content

I am trying to populate a template field using an if/then based on another field in the model. Specifically, I am looking to do: IF State (field) = CA, THEN populate template filed as Pacific. I cannot find anyone who has posted a solution for this! Does anyone have a solution?

Hi Ryan,

On this documentation page, under “Sections” you’ll see some explanation of the truthy/falsy capabilities available in Merge Syntax. 

In short, you can set up an if/then statement like this:


{{#IsActive}}Sell this product!{{/IsActive}}{{^IsActive}}Pretend this product doesn't exist!{{/IsActive}}


What this will do is check whether the boolean field IsActive is true, using {{#IsActive}}. The # stands in for “if”. If true, it will display the content that follows it, up to the closing tag, which in this case is {{/IsActive}}. 

Right after that, you have what amounts to an “IfFalse” signified with the ^, which behaves the same. If “IsActive” is not true, it will display the contents following, up to the close tag {{/IsActive}}. I’d recommend checking out the link above for more details. 

I hope this helps you in your use case!


Thanks Mark. It makes sense, but I’m still not sure how to add the ‘=’ part of it…so would it specifically be {{#State=CA}}Pacific{{/State_C}}{{^State_c}}Other{{/State_c}}

I guess my question is around how do I know when the statement is true without the =?


Hey Ryan!

So you’ll actually need a formula field to accomplish what you’re trying to do here.  If you’re specifically checking if the State = “CA”, create a UI-Only formula field, which we’ll call “ifStateCA”:


if({{State}}=="CA", true, false)

Then what you’re going to write in your template would be:


{{#ifStateCA}}Pacific{{/ifStateCA}}{{^ifStateCA}}Other{{/ifStateCA}}

What this is essentially saying is:
IF “ifStateCA” is true or not null, display Pacific
IF “ifStateCA” is false or null, display Other

Hope this makes sense!
Christine