Velocity Scripting to change displayed token value | Community
Skip to main content
Level 2
April 5, 2024
Solved

Velocity Scripting to change displayed token value

  • April 5, 2024
  • 1 reply
  • 2482 views

Ok I am doing nothing very complicated. I am looking at a field which is a picklist of values (specifically currency type). Based on that I need to display a very specific value. I started to write a velocity scrip and tested it and got it to partially work, but when I changed the value to be the price it stopped working. If I could get advice on how to fix this I appreciate it. I put the never version of the script below and appreciate any advise on what I am doing wrong.

 

##contact currency preference and print specific currency value #if(${lead.CurrencyIsoCode}=="USD") #$180 #elseif(${lead.CurrencyIsoCode}=="EUR") #€144 #elseif(${lead.CurrencyIsoCode}=="AUS") #$277.20 #elseif(${lead.CurrencyIsoCode}=="JPY") #¥18,000 #elseif(${lead.CurrencyIsoCode}=="CAD") #$252 #elseif(${lead.CurrencyIsoCode}=="GBP") #£144 #else(${lead.CurrencyIsoCode}==$NULL) #{lead.CurrencyIsoCode} #end

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman
  • Don’t use ${formal} references inside directives, use $simple
  • Don’t use the == operator, use .equals (== causes hard-to-debug errors)
  • Don’t use literal $ to print a dollar sign, use ${esc.d}
  • Your last #else doesn’t make sense, #else doesn’t have conditions

 

##contact currency preference and print specific currency value #if( $lead.CurrencyIsoCode.equals("USD") ) ${esc.d}180 #elseif( $lead.CurrencyIsoCode.equals("EUR") ) €144 #elseif( $lead.CurrencyIsoCode.equals("AUS") ) ${esc.d}277.20 #elseif( $lead.CurrencyIsoCode.equals("JPY") ) ¥18,000 #elseif( $lead.CurrencyIsoCode.equals("CAD") ) ${esc.d}252 #elseif( $lead.CurrencyIsoCode.equals("GBP") ) £144 #else ${lead.CurrencyIsoCode} #end

 

 

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
April 5, 2024
  • Don’t use ${formal} references inside directives, use $simple
  • Don’t use the == operator, use .equals (== causes hard-to-debug errors)
  • Don’t use literal $ to print a dollar sign, use ${esc.d}
  • Your last #else doesn’t make sense, #else doesn’t have conditions

 

##contact currency preference and print specific currency value #if( $lead.CurrencyIsoCode.equals("USD") ) ${esc.d}180 #elseif( $lead.CurrencyIsoCode.equals("EUR") ) €144 #elseif( $lead.CurrencyIsoCode.equals("AUS") ) ${esc.d}277.20 #elseif( $lead.CurrencyIsoCode.equals("JPY") ) ¥18,000 #elseif( $lead.CurrencyIsoCode.equals("CAD") ) ${esc.d}252 #elseif( $lead.CurrencyIsoCode.equals("GBP") ) £144 #else ${lead.CurrencyIsoCode} #end

 

 

 

Eric1001Author
Level 2
April 5, 2024

Thank you so much for helping me review this and correct the mistakes.