Velocity Script Not Populating In Email | Community
Skip to main content
michellechopin
Community Advisor
Community Advisor
July 1, 2025
Solved

Velocity Script Not Populating In Email

  • July 1, 2025
  • 2 replies
  • 2061 views

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:

  • Should there be a closing bracket at the end of lines like this?: #elseif ($lead.Support_Type__c.equals("Gold Success Plan") 
  • Should there be an opening bracket at the start of lines like this?: $lead.Public_Sector_Subsegment__c.equals("SLED - Higher Ed - ENT") 

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

 

Best answer by SanfordWhiteman

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

2 replies

PeeyushSachdeva
Level 4
July 1, 2025

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:

  • Properly grouped all AND/OR conditions using parentheses to ensure correct evaluation.
  • Added null-safety checks to avoid potential runtime errors when fields are empty.
  • Removed redundant/duplicate conditions to streamline the logic.
  • Standardized HTML output formatting and spacing.
  • Included a fallback #else block, so there's always some output even if no conditions match.

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
michellechopin
Community Advisor
Community Advisor
July 1, 2025

@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 😀

michellechopin
Community Advisor
Community Advisor
July 1, 2025

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: 

  • The text you cleaned up: $lead.Account_Owner_Sales_Segment__c &&
  • The text when I drag in a field: ${lead.Account_Owner_Sales_Segment__c} &&

Appreciate your help and expertise so much!

Michelle 😊

SanfordWhiteman
Level 10
July 1, 2025

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 ) )

 

michellechopin
Community Advisor
Community Advisor
July 1, 2025

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 🙂

SanfordWhiteman
Level 10
July 1, 2025

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!)