Conditional display in script token | Community
Skip to main content
Level 2
Apr 23, 2021 10:20 PM UTC
Solved

Conditional display in script token

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Apr 23, 2021 10:32 PM UTC

In Velocity, everything that's outside of a #directive is automatically output.

 

So you're overcomplicating things (and there's also a syntax error, but we can resolve that by not having any special syntax at all).

 

All you need is:

#if( $lead.mktohiddenadminstring1.equals("21Q2-incentive-form") ) Thank you for submitting your brand for consideration for our Growth Spurt Campaign. #end

If the condition doesn't match, there's no output.

 


Also, is there a way I can control the formatting of this sentence, such as font, size...

Certainly. You can output HTML tags and styles, Velocity just outputs whatever you tell it to:

#if( $lead.mktohiddenadminstring1.equals("21Q2-incentive-form") ) Thank you for submitting your brand for consideration for our <strong>Growth Spurt Campaign.</strong>. #end

 

4 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Apr 23, 2021 10:32 PM UTC

In Velocity, everything that's outside of a #directive is automatically output.

 

So you're overcomplicating things (and there's also a syntax error, but we can resolve that by not having any special syntax at all).

 

All you need is:

#if( $lead.mktohiddenadminstring1.equals("21Q2-incentive-form") ) Thank you for submitting your brand for consideration for our Growth Spurt Campaign. #end

If the condition doesn't match, there's no output.

 


Also, is there a way I can control the formatting of this sentence, such as font, size...

Certainly. You can output HTML tags and styles, Velocity just outputs whatever you tell it to:

#if( $lead.mktohiddenadminstring1.equals("21Q2-incentive-form") ) Thank you for submitting your brand for consideration for our <strong>Growth Spurt Campaign.</strong>. #end

 

Translate
Emma_WuAuthor
Level 2
Apr 23, 2021 10:47 PM UTC

Thank you @sanfordwhiteman - I have used the code you sent, and I still hit an error: "Cannot get email content- A newline character is expected at the end of Email Script". Do you know what that is referring to?

Translate
SanfordWhiteman
Level 10
Apr 23, 2021 11:01 PM UTC

Means you need a line break after the #end directive.

Translate