Edited: Includes additional comment as a postscript.
Hello Community,
I am working on reusing some Velocity Script in a token that my team used last year for our industry event Abandoned Registration email/process; after updating only the dynamic content within it (I didn't change any of the parameters or fields), the script isn't working in my test emails or when I use a person to preview the email in Marketo.
I'm extremely unfamiliar with VS so would love some expert eyeballs on the script to see what's wrong (hoping it's an errant space or comma 😛). However, as I'm writing this, I see that there are a few () missing in various places - would inconsistencies with things like that cause the entire script to fail/break?
For example:
Here's the script that I'm using - from a function perspective, the various elements look to be correct (#elseif, #output etc) based on what I've read online (one article that I referenced) so I'm assuming it's these missing brackets or some errant space/character that I've yet to identify:
## Determines discount offering based on audience targeting segments
#if ($lead.NPO_Classification__c.equals("Approved"))
##output
<strong>A special discount just for you</strong>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif ($lead.Support_Type__c.equals("Gold Success Plan") || $lead.Support_Type__c.equals("Premier Plus") || $lead.Support_Type__c.equals("Premier Plus Support") || $lead.Support_Type__c.equals("Premier Plus Success") || $lead.Support_Type__c.equals("Premier Plus Success Package") || $lead.Support_Type__c.equals("Courtesy Premier Plus"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Silver Success Plan"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Premier Access Success"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for<strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Premier") || $lead.Support_Type__c.equals("Premier Success Package") || $lead.Support_Type__c.equals("Premier Support") || $lead.Support_Type__c.equals("Premier Success"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Account_Owner_Sales_Segment__c.equals("Federal") ||
($lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
($lead.Public_Sector_Subsegment__c.equals("Federal - Civilian") || $lead.Public_Sector_Subsegment__c.equals("Federal - Other")) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian") || $lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other"))) ||
($lead.Primary_Industry__c_lead.equals("Government") || $lead.Primary_Industry__c.equals("Government")))
##output
<strong>A special discount just for you</strong>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif ($lead.Account_Owner_Sales_Segment__c.equals("SLED") ||
($lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
($lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - State") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Public Sector") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Central Gov") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Local Gov") || $lead.Public_Sector_Subsegment__c.equals("EMEA - Healthcare")) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - State") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Public Sector") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Central Gov") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Local Gov") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Healthcare"))) ||
($lead.Primary_Industry__c_lead.equals("Education") || $lead.Primary_Industry__c.equals("Education")))
##output
<strong>A special discount just for you</strong>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#end
This is how the editor looks:
This is how the preview/test email looks (when previewing with a person that meets the criteria for one of the groups in the VS):
Any help/direction/insight is always appreciated (as is validation that my assumption is right - I'm fiddling with the script on my end as we speak!).
TIA 😊
Michelle
PS. Just made all those changes in the script and when I went to send a test, I got this error - however, I can't see the details of it (not to mention the spelling error in it 🤣) so I don't know what the actual issue is or how to fix it:
Error Message
Edited script:
## Determines discount offering based on audience targeting segments
#if ($lead.NPO_Classification__c.equals("Approved"))
##output
<strong>A special discount just for you</strong>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif ($lead.Support_Type__c.equals("Gold Success Plan”)) || $lead.Support_Type__c.equals("Premier Plus”)) || ($lead.Support_Type__c.equals("Premier Plus Support”)) || ($lead.Support_Type__c.equals("Premier Plus Success”)) || ($lead.Support_Type__c.equals("Premier Plus Success Package”)) || ($lead.Support_Type__c.equals("Courtesy Premier Plus"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Silver Success Plan"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Premier Access Success"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for<strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c.equals("Premier”)) || ($lead.Support_Type__c.equals("Premier Success Package”)) || ($lead.Support_Type__c.equals("Premier Support”)) || ($lead.Support_Type__c.equals("Premier Success"))
##output
<strong>A special discount just for you</strong>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Account_Owner_Sales_Segment__c.equals("Federal”)) ||
($lead.Account_Owner_Sales_Segment__c.equals("Public Sector”)) &&
($lead.Public_Sector_Subsegment__c.equals("Federal - Civilian”)) || ($lead.Public_Sector_Subsegment__c.equals("Federal - Other")) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian”)) || ($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other")) ||
($lead.Primary_Industry__c_lead.equals("Government”)) || ($lead.Primary_Industry__c.equals("Government"))
##output
<strong>A special discount just for you</strong>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif ($lead.Account_Owner_Sales_Segment__c.equals("SLED”)) ||
($lead.Account_Owner_Sales_Segment__c.equals("Public Sector”)) &&
($lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - CML”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - State”)) ||
($lead.Public_Sector_Subsegment__c.equals("EMEA - Public Sector”)) ||
($lead.Public_Sector_Subsegment__c.equals("EMEA - Central Gov”)) ||
($lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML”)) ||
($lead.Public_Sector_Subsegment__c.equals("EMEA - Local Gov”)) || ($lead.Public_Sector_Subsegment__c.equals("EMEA - Healthcare")) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - CML”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - State”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Public Sector”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Central Gov”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Local Gov”)) ||
($lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Healthcare")) ||
($lead.Primary_Industry__c_lead.equals("Education”)) || ($lead.Primary_Industry__c.equals("Education"))
##output
<strong>A special discount just for you</strong>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#end
Solved! Go to Solution.
Looking much more manageable and nice work with the sets/lists.
See that you’re using curly quotes in several places, though, which will not work. Gotta be straight quotes "
! Also, a few syntax errors remained. So you can start from here:
## Determines discount offering based on audience targeting segments
#set( $PublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $MatchedAccountsPublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $AccountPassTypeGold = [
"Gold Success Plan",
"Premier Plus",
"Premier Plus Support",
"Premier Plus Success",
"Premier Plus Success Package",
"Courtesy Premier Plus"
])
#set( $AccountPassTypePremier = [
"Premier",
"Premier Success Package",
"Premier Support",
"Premier Success"
])
#if( $lead.NPO_Classification__c && $lead.NPO_Classification__c.equals("Approved") )
<strong>A special discount just for you</strong><br/>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif( $AccountPassTypeGold.contains($lead.Support_Type__c) )
<strong>A special discount just for you</strong><br/>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $lead.Support_Type__c.equals("Silver Success Plan"))
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $lead.Support_Type__c.equals("Premier Access Success"))
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $AccountPassTypePremier.contains($lead.Support_Type__c) )
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif(
$lead.Account_Owner_Sales_Segment__c.equals("Federal") ||
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
$lead.Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.Public_Sector_Subsegment__c.equals("Federal - Other") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other") ||
$lead.Primary_Industry__c_lead.equals("Government") ||
$lead.Primary_Industry__c.equals("Government")
)
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif(
$lead.Account_Owner_Sales_Segment__c.equals("SLED") ||
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
$PublicSectorSubSegments.contains( $lead.Public_Sector_Subsegment__c ) ||
$MatchedAccountsPublicSectorSubSegments.contains( $lead.MatchedAccount_Public_Sector_Subsegment__c ) ||
$lead.Primary_Industry__c_lead.equals("Education") ||
$lead.Primary_Industry__c.equals("Education")
)
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#end
I find these giant boolean conditions way over the border into unreadability, even after the rewrite.
Don’t do stuff that way. Instead, declare your lists of interesting values at the top:
#set( $interestingPublicSectorSubsegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
Then you can check if a field value is in that list in one simple statement:
#if( $interestingPublicSectorSubsegments.contains( $lead.Public_Sector_Subsegment__c ) )
It makes for a VERY long script, I agree!
With your suggestion in mind, where does the #set section fit in the PubSec area?
Additionally, question in terms of how to read the script - does $lead.Account_Owner_Sales_Segment__c with no detail specified just mean that it's looking for a record with that information populated (i.e. is not empty)? Otherwise it seems redundant but, as before, I'm not at ALL familiar with VS!
Appreciate your help 🙂
With your suggestion in mind, where does the #set section fit in the PubSec area?🙂
You can put all such “interesting lists” at the top of the token (which also makes them much easier to edit). They have to be declared before they’re used.
Additionally, question in terms of how to read the script - does $lead.Account_Owner_Sales_Segment__c with no detail specified just mean that it's look for a record with that information populated (i.e. is not empty)? Otherwise it seems redundant but, as before, I'm not at ALL familiar with VS!
It matches when the property is not null and not false.
But it can never be either of those things. It can only be an empty String or a non-empty String.
(That’s why in my earlier reply I noted it’s redundant — you’re right!)
Got it - and this all makes sense!
I'm adding the various sets at the top of the token (going to use them for the couple of places where there are a lot of options).
How do I reference the set later on in the script? Would I use a command like this:
$lead.Support_Type__c.equals("Gold Success Plan")
And replace "Gold Success Plan" with something so it knows to reference the list? And if so, what should I include there?
This is my first time playing with a VS that's not a copyright date in an email footer so I appreciate all the guidance with a more complex code 🙂
How do I reference the set later on in the script? Would I use a command like this:
$lead.Support_Type__c.equals("Gold Success Plan")
#if( $interestingPublicSectorSubsegments.contains( $lead.Public_Sector_Subsegment__c ) )
You’re checking if the list of interesting values contains the field value.
I think I have it!
With all those details in mind, I've removed the redundant fields, added sets, and referenced those sets in place of the list of fields (and hopefully captured the logic correctly too). Would you be so kind as to take a look at the script and let me know how it looks:
## Determines discount offering based on audience targeting segments
#set( $PublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $MatchedAccountsPublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $AccountPassTypeGold = [
“Gold Success Plan”,
“Premier Plus”,
“Premier Plus Support”,
“Premier Plus Success”,
“Premier Plus Success Package”,
“Courtesy Premier Plus”
])
#set( $AccountPassTypePremier = [
“Premier”,
“Premier Success Package”,
“Premier Support”,
“Premier Success”
])
#if ($lead.NPO_Classification__c && $lead.NPO_Classification__c.equals("Approved"))
##output
<strong>A special discount just for you</strong><br/>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif( $AccountPassTypeGold.contains ($lead.Support_Type__c))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif( $lead.Support_Type__c.equals("Silver Success Plan"))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif( $lead.Support_Type__c.equals("Premier Access Success"))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif( $AccountPassTypePremier.contains ($lead.Support_Type__c))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif( $lead.Account_Owner_Sales_Segment__c.equals("Federal”)) ||
( $lead.Account_Owner_Sales_Segment__c.equals("Public Sector”)) &&
( $lead.Public_Sector_Subsegment__c.equals("Federal - Civilian”)) ||
( $lead.Public_Sector_Subsegment__c.equals("Federal - Other”)) ||
( $lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian”)) ||
( $lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other”)) ||
($lead.Primary_Industry__c_lead && $lead.Primary_Industry__c_lead.equals("Government")) ||
($lead.Primary_Industry__c && $lead.Primary_Industry__c.equals("Government"))
##output
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif( $lead.Account_Owner_Sales_Segment__c.equals("SLED”)) ||
( $lead.Account_Owner_Sales_Segment__c.equals("Public Sector”)) &&
( $PublicSectorSubSegments.contains ( $lead.Public_Sector_Subsegment__c)) ||
( $MatchedAccountsPublicSectorSubSegments.contains ( $lead.MatchedAccount_Public_Sector_Subsegment__c)) ||
( $lead.Primary_Industry__c_lead && $lead.Primary_Industry__c_lead.equals("Education")) ||
($lead.Primary_Industry__c && $lead.Primary_Industry__c.equals("Education"))
##output
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#end
I removed the final output that was suggested prior because, in this case, if someone doesn't fit one of those groups, they don't get a special offer at the bottom of the reminder email (but I'm going to keep this in mind for future uses as it's valuable).
TIA @SanfordWhiteman 🙂
Looking much more manageable and nice work with the sets/lists.
See that you’re using curly quotes in several places, though, which will not work. Gotta be straight quotes "
! Also, a few syntax errors remained. So you can start from here:
## Determines discount offering based on audience targeting segments
#set( $PublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $MatchedAccountsPublicSectorSubSegments = [
"SLED - Higher Ed - CML",
"SLED - Higher Ed - ENT",
"SLED - Local Government - CML",
"SLED - Local Government - ENT",
"SLED - Lower Education - CML",
"SLED - Lower Education - ENT",
"SLED - State",
"EMEA - Public Sector",
"EMEA - Central Gov",
"EMEA - Local Gov",
"EMEA - Healthcare"
] )
#set( $AccountPassTypeGold = [
"Gold Success Plan",
"Premier Plus",
"Premier Plus Support",
"Premier Plus Success",
"Premier Plus Success Package",
"Courtesy Premier Plus"
])
#set( $AccountPassTypePremier = [
"Premier",
"Premier Success Package",
"Premier Support",
"Premier Success"
])
#if( $lead.NPO_Classification__c && $lead.NPO_Classification__c.equals("Approved") )
<strong>A special discount just for you</strong><br/>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif( $AccountPassTypeGold.contains($lead.Support_Type__c) )
<strong>A special discount just for you</strong><br/>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $lead.Support_Type__c.equals("Silver Success Plan"))
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $lead.Support_Type__c.equals("Premier Access Success"))
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif( $AccountPassTypePremier.contains($lead.Support_Type__c) )
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the "checkout" page.
#elseif(
$lead.Account_Owner_Sales_Segment__c.equals("Federal") ||
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
$lead.Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.Public_Sector_Subsegment__c.equals("Federal - Other") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other") ||
$lead.Primary_Industry__c_lead.equals("Government") ||
$lead.Primary_Industry__c.equals("Government")
)
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif(
$lead.Account_Owner_Sales_Segment__c.equals("SLED") ||
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
$PublicSectorSubSegments.contains( $lead.Public_Sector_Subsegment__c ) ||
$MatchedAccountsPublicSectorSubSegments.contains( $lead.MatchedAccount_Public_Sector_Subsegment__c ) ||
$lead.Primary_Industry__c_lead.equals("Education") ||
$lead.Primary_Industry__c.equals("Education")
)
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#end
@SanfordWhiteman I appreciate you and your support, thank you!
I was editing this script in Notes and I couldn't work out how to change between curly vs straight quotes - apparently that tool does it automatically as I watched it change as I typed in " (it looks like it's auto-italicising them). I probably shouldn't use that to edit code and will remember that for next time.
I'm going to test this out now and see how things go on my end.
Thank you thank you 🙏
I was editing this script in Notes and I couldn't work out how to change between curly vs straight quotes - apparently that tool does it automatically as I watched it change as I typed in " (it looks like it's auto-italicising them). I
Yes, that’s a common struggle. I have a Windows addon that changes straight quotes to curly but I have to make sure it’s only active here and on my blog, not in my text editor!
I'll try using TextEdit next time (I'm on a Mac) or see if there's a better tool for working on code, as those are tiny things that my untrained eye would never notice (and would cause me to lose my mind when something breaks 😝).
Hi @michellechopin ,
I’ve gone ahead and cleaned up the original Velocity script for clarity, structure, and functionality. Here are the key updates I made:
Note: Don’t forget to select all required lead fields (and any custom fields) from the right-side menu in the script editor — this is a common reason why scripts silently fail in Marketo.
Here’s the cleaned version of the script (attached below). Feel free to test it and tweak the messages if needed.
-----------------
## Determines discount offering based on audience targeting segments
#if ($lead.NPO_Classification__c && $lead.NPO_Classification__c.equals("Approved"))
##output
<strong>A special discount just for you</strong><br/>
As a nonprofit, your organization gets <strong>five free Oktane Standard passes</strong> (register using your .org email address).
#elseif (
$lead.Support_Type__c &&
(
$lead.Support_Type__c.equals("Gold Success Plan") ||
$lead.Support_Type__c.equals("Premier Plus") ||
$lead.Support_Type__c.equals("Premier Plus Support") ||
$lead.Support_Type__c.equals("Premier Plus Success") ||
$lead.Support_Type__c.equals("Premier Plus Success Package") ||
$lead.Support_Type__c.equals("Courtesy Premier Plus")
)
)
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for up to <strong>six free Oktane Standard passes</strong> (and, 50% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c && $lead.Support_Type__c.equals("Silver Success Plan"))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>one free Oktane Standard pass</strong> (and, 30% off additional passes) because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif ($lead.Support_Type__c && $lead.Support_Type__c.equals("Premier Access Success"))
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>50% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif (
$lead.Support_Type__c &&
(
$lead.Support_Type__c.equals("Premier") ||
$lead.Support_Type__c.equals("Premier Success Package") ||
$lead.Support_Type__c.equals("Premier Support") ||
$lead.Support_Type__c.equals("Premier Success")
)
)
##output
<strong>A special discount just for you</strong><br/>
Your organization qualifies for <strong>30% off Oktane Standard passes</strong> because of your Premier Success Plan. When you register, just apply your unique discount code (contact your CSM to get it, if you haven't yet) on the “checkout” page.
#elseif (
(
$lead.Account_Owner_Sales_Segment__c &&
(
$lead.Account_Owner_Sales_Segment__c.equals("Federal") ||
(
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
(
$lead.Public_Sector_Subsegment__c &&
(
$lead.Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.Public_Sector_Subsegment__c.equals("Federal - Other")
)
)
)
)
) ||
(
$lead.MatchedAccount_Public_Sector_Subsegment__c &&
(
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Civilian") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("Federal - Other")
)
) ||
(
($lead.Primary_Industry__c_lead && $lead.Primary_Industry__c_lead.equals("Government")) ||
($lead.Primary_Industry__c && $lead.Primary_Industry__c.equals("Government"))
)
)
##output
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#elseif (
(
$lead.Account_Owner_Sales_Segment__c &&
(
$lead.Account_Owner_Sales_Segment__c.equals("SLED") ||
(
$lead.Account_Owner_Sales_Segment__c.equals("Public Sector") &&
(
$lead.Public_Sector_Subsegment__c &&
(
$lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT") ||
$lead.Public_Sector_Subsegment__c.equals("SLED - State") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Public Sector") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Central Gov") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Local Gov") ||
$lead.Public_Sector_Subsegment__c.equals("EMEA - Healthcare")
)
)
)
)
) ||
(
$lead.MatchedAccount_Public_Sector_Subsegment__c &&
(
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Local Government - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - CML") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - Lower Education - ENT") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("SLED - State") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Public Sector") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Central Gov") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Local Gov") ||
$lead.MatchedAccount_Public_Sector_Subsegment__c.equals("EMEA - Healthcare")
)
) ||
(
($lead.Primary_Industry__c_lead && $lead.Primary_Industry__c_lead.equals("Education")) ||
($lead.Primary_Industry__c && $lead.Primary_Industry__c.equals("Education"))
)
)
##output
<strong>A special discount just for you</strong><br/>
As a Public Sector org, you get <strong>20% off</strong> the current price for each Oktane Standard pass you purchase (register using a .gov, .edu, .mil email).
#else
##output
<strong>Join us at Oktane!</strong><br/>
We'd love to have you at the event. Register today and check with your CSM or marketing contact to see if you qualify for any discounts.
#end
Added null-safety checks to avoid potential runtime errors when fields are empty.
You don’t need to do this, though. Assuming you mean
#if( $lead.Support_Type__c )
this will always be true because lead fields are always Strings in Velocity. They won’t be null
, they can only be empty Strings or non-empty Strings.
And Strings are always true.
@PeeyushSachdeva you are so kind to clean up everything for me!
I've put it into the token and am working to update the fields from the right side (when I did a quick preview test, the email content doesn't change for a person that is meant to be a member of one of those groups). One thing I'm noticing is that none of the fields are showing as selected from the right rail/bar - is that because I've just pasted things in and it doesn't automatically pick things up or is that because I have to go through and manually select them to go into the script (assuming that, when one builds a script from scratch, they're doing so IN this editor)?
Looking at the NPO field as an example (up at the top of the code), I don't even see a field that corresponds to that in general which makes me wonder if that's why the script isn't working:
I'm going to check on this in general because, if fields HAVE changed, I'm going to need to know what each one means to make sure I include the right ones.
Thank you again so much for cleaning this up for me and directing me too 😀
Extra question for you @PeeyushSachdeva - when I pull the field from the side menu into the editor, it shows up with curly brackets. If I pull all the fields into their respective spots, is it safe to assume the best practice is to remove those curly brackets?
For example:
Appreciate your help and expertise so much!
Michelle 😊
If I pull all the fields into their respective spots, is it safe to assume the best practice is to remove those curly brackets?
The best practice inside #directives
(like #if
blocks) is to not use curly braces, or what’s called formal notation.
But the best practice in output (that is, outside #directives
) is to use curly braces.
In both cases you’re reducing ambiguity.
Given that I have a LOT of fields to update in here, what option is best? I don't want to remove them all and then have to add them back in (or vice versa) 😛
Given that I have a LOT of fields to update in here, what option is best? I don't want to remove them all and then have to add them back in (or vice versa) 😛
There is no one best option. It depends on where they’re used. In your case you aren’t outputting any fields, so don’t use ${formal.references}
, use $simple.references
.
But in the future, if you do output, remember to use ${formal}
.
Excuse the noob question but what do you mean when you say I'm "not outputting any fields"?
I'll go through and connect the fields from the list to make sure everything is pulling in properly but will remove the {} as I go!
@michellechopin wrote:
Excuse the noob question but what do you mean when you say I'm "not outputting any fields"?
I'll go through and connect the fields from the list to make sure everything is pulling in properly but will remove the {} as I go!
Meaning you’re not printing any fields as-is.
Printing a field:
Your balance is ${lead.balance}.
Checking a a field in a #directive
but not printing it:
#if( $lead.balance > 99 )
You’re over your limit.
#end