SOLVED

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

Go to solution
Anonymous
Not applicable

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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

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

Sorry, Tom

Please try this code

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

#if ($foo == 1 )

Yes

#else

No

#end

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

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

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.

Anonymous
Not applicable

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

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.

Anonymous
Not applicable

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

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

Anonymous
Not applicable

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

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

Email script.bmp

Erorr message.bmp

Best regards

Tom

Neil_Robertson6
Level 5

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

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

Anonymous
Not applicable

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

Sorry, Tom

Please try this code

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

#if ($foo == 1 )

Yes

#else

No

#end

Anonymous
Not applicable

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

Thanks for all the help - It is working now