SOLVED

If/else email script format?

Go to solution
Anonymous
Not applicable

If/else email script format?

Hi..

It's my first time trying to set up an email script - a simple if/else that writes content and links to an email, based on what's in a specific field - lead.lastRequestedAssetType. I found a quick tutorial site that covers this ( http://developers.marketo.com/documentation/velocity-script/  ),  but it doesn't seem to be working in my example.

I've written this as a script:

## If webinar

#if(${lead.lastRequestedAssetType} == "Webinar")

    #set($assetlink = "http://www.website.com/webinar ${lead.lastRequestedAssetType}.html")

## If White Paper

#elseif(${lead.lastRequestedAssetType} == "WhitePaper")

    #set($assetlink = "http://whitepaper ${lead.lastRequestedAssetType}.pdf")

## If Case Study

#elseif(${lead.lastRequestedAssetType} == "CaseStudy")

    #set($assetlink = "http://www.website.com/webinar${lead.lastRequestedAssetType}.pdf")

#else

    #set($assetlink = "http://default.${lead.lastRequestedAssetType}.end of link")

#end

##print it out

${assetlink}

I have two problems:

1- When I test the email, It seems to be skipping all the if statements, and going to default, even though the database field is filled out correctly.

2- my result is exactly what's in the default: http://default.${lead.lastRequestedAssetType}.end of link

    It's not filling in the lead.lastRequestedAssetType, to give me something like: "http:default.linktoitem.end of link"

Thank you for any suggestions.

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: If/else email script format?

Oh. That's correct.

That is a 'gotcha' where I have spent some time figuring our myself an year back.

It comes back in effect if you clone a script token. You might have to manually 'check' these appropriate checkboxes for the cloned script token.

I did not mention it as I thought you have that all done. Glad that it is working for you.

Rajesh

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Re: If/else email script format?

Hi Charles,

How are you 'testing' this email?

Velocity Script do not get evaluated and rendered when you use 'Send a sample' or any 'send test' method we usually do to test a Marketo email.

Create a test lead, and actually send this email to that lead using a 'test' smart campaign.

That's when the velocity script will be evaluated and you will be able to test it.

Please feel free to DM me if you have any issues.

Rajesh

Anonymous
Not applicable

Re: If/else email script format?

Thank you, Rajesh, for your response...

I was looking at the Preview screen and had set it to apply to a specific list with test emails. Then I was toggling between test emails. I could see some simpler items changing, but not this if/else. I think part of the problem had something to do with saving drafts. I've got #1 solved. It seems to be switching between the statements. I sent a test email to verify this.

#2 still seems to be a problem. I don't know if I'm missing something in the syntax, but it's just printing out my tag as text, instead of using it to populate that area with the field's actual contents. I'm just getting: http://whitepaper.${lead.lastRequestedAssetType}.pdf actually printed into the email. It did the same in my test email.

Anonymous
Not applicable

Re: If/else email script format?

oh! Wait! I solved it! I didn't realize, for whatever reason, I had to check a box in the list at right, next to the item I wanted to use in my code.

Anonymous
Not applicable

Re: If/else email script format?

Oh. That's correct.

That is a 'gotcha' where I have spent some time figuring our myself an year back.

It comes back in effect if you clone a script token. You might have to manually 'check' these appropriate checkboxes for the cloned script token.

I did not mention it as I thought you have that all done. Glad that it is working for you.

Rajesh

View solution in original post