Conditional display in script token | Community
Skip to main content
Level 2
April 23, 2021
Solved

Conditional display in script token

  • April 23, 2021
  • 1 reply
  • 3953 views
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
April 23, 2021

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

 

Emma_WuAuthor
Level 2
April 23, 2021

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?

SanfordWhiteman
Level 10
April 23, 2021

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