Email script for booelan field with velocity code - how to do? | Community
Skip to main content
September 28, 2015
Solved

Email script for booelan field with velocity code - how to do?

  • September 28, 2015
  • 5 replies
  • 2608 views

Hi

As a very new person to marketo I need a some help with this. I am trying to create a small email script so that the value true is rpelaced with yes in the email and the value blank is replaced with No. A token is created on the program and I select email token. Then I insert the following

# if (${lead.Customer_expect_to_be_contacted_by_Sales__c}== "true" )

Yes

# else

No

# END

Then I insert the token into my email, but when I test it it dosent insert the value Yes/No but the code. It is like it treats the code as plain text or something. The result in the meail lokks like this # if (1== "true" ) Yes # else No # END.

I found this example on the forum

#if(${lead.fieldname} == "fieldvalue1")

Email text here

#elseif (${lead.fieldname} == "fieldvalue2")

Email text here

#else

Email text here

#end

Is there somebody who can tell me what I am doing wrong.

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

Sorry, Tom

Please try this code

#set( $foo = ${lead.Customer_expect_to_be_contacted_by_Sales__c} )

#if ($foo == 1 )

Yes

#else

No

#end

5 replies

September 28, 2015

Hi Tom,

Not sure, but what type of token have you selected?  I have a similar token and for me it works but the token type has to be "Email Script".  If you select a different type this might be causing this behavior.

Hope that helps.

September 28, 2015

First, delete those spaces after the #. It should be #if not # if.

Second, double check that you have that field checked in the list on the right side.

If that doesn't fix it, screenshots would help.

September 29, 2015

Hi Tom

This code works file.

#set( $foo = ${lead.Marketing_Suspended})

FOO = $foo

#if( $foo == 1 )

Marketing_Suspend1 is TRUE

#else

Marketing_Suspend1 is FALSE

#end

So, try below.

#if (${lead.Customer_expect_to_be_contacted_by_Sales__c} == 1 )

Yes

#else

No

#END

September 29, 2015

HI All

Thanks for all the good input. I have changed the code but now I am running into this errors. Below is a picture of the current code and the error message I receive when trying to email a sample

Best regards

Tom

Neil_Robertson6
Level 4
September 29, 2015

Change #END to be #end  (note the syntax highlighting which is showing you it is not correct)

September 29, 2015

Thanks for all the help - It is working now