SOLVED

Re: Using Email Script to print out subscriptions

Go to solution
Liz_Davalos
Level 3

Using Email Script to print out subscriptions

Edited for current code: We have several newsletters and I've been trying to get a script working that checks if someone is subscribed and if so lists the newsletter name. For some reason I just can't get it to work even though this script is identical (except for the field used) to others I'm using that work. It is a boolean field, not sure if maybe I'm doing something with that wrong?

Also if you have any recommendations for pulling a list of subscriptions it would be appreciated. If was just going to do a bunch of if statements.

#if( $lead.TrendlinesSubscription == "1" )

  #set ( $subtrendslines = "Trendlines" )

#else

  #set ( $subtrendslines = "None" )

#end

${subtrendslines}

This is the error:

An error occurred when procesing the email Rendered_Email_Velocity_Error_Area_unkown!

Encountered "" near

${mktmail.Optout_text}
@___MKTMAIL___@:END
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script to print out subscriptions

That code snippet itself is (now) fine. If that's the whole of the token, and the only token in the email, I think it's something else in your email that's causing a Velocity error (all Marketo emails use Velocity, even without an explicit Email Script token).

Look in the email content for the characters # and $. Remove them to test.

View solution in original post

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script to print out subscriptions

In Velocity, Marketo Boolean fields are represented as the string "1" or the empty string "".

Liz_Davalos
Level 3

Re: Using Email Script to print out subscriptions

Oh, ok. Well that would be why True isn't working. Thank you!

Liz_Davalos
Level 3

Re: Using Email Script to print out subscriptions

Ok, I modified it and it still causes an error...

#if ( $lead.TrendlinesSubscription = "1" )

  #set ( $subtrendslines = "Trendlines" )

#else

  #set ($subtrendslines = "")

#end

${subtrendslines}

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script to print out subscriptions

Equality operator is two equals signs (==)

Liz_Davalos
Level 3

Re: Using Email Script to print out subscriptions

I've tried double equal, with and without parentheses, double equals everywhere and just at the top. It just won't work.

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script to print out subscriptions

I've tried double equal, with and without parentheses, double equals everywhere and just at the top. It just won't work.

Well, every fix you've made so far was critical. You can't use == everywhere, it's the equality check operator, not the assignment (#set) operator.  Assignment is always via =.

I don't know where you'd be leaving off parentheses as Velocity #directives() must use parens.

What's still not working exactly?

Do you have the field checked off in the tree on the right side of Script Editor?

Liz_Davalos
Level 3

Re: Using Email Script to print out subscriptions

Field is checked off in the script editor. I added the current error to the original post and updated the code to the current version that still doesn't work.

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script to print out subscriptions

That code snippet itself is (now) fine. If that's the whole of the token, and the only token in the email, I think it's something else in your email that's causing a Velocity error (all Marketo emails use Velocity, even without an explicit Email Script token).

Look in the email content for the characters # and $. Remove them to test.

Liz_Davalos
Level 3

Re: Using Email Script to print out subscriptions

Yep, I had another token in there that was broken. Thank you for the help, I'm starting to figure this stuff out.