AnsweredAssumed Answered

Math operators in Velocity?

Question asked by Ronnie Duke on Oct 14, 2019
Latest reply on Nov 29, 2019 by Sanford Whiteman

Hello all,


Has anyone tried using basic math operators in Velocity in Marketo? The documentation says I should be able to use simple arithmetic in my variables, but for some reason they do not work in Marketo. 


I am trying to take take number fields and convert them to percentages for calculations in my email:

#set( $test = ${lead.Some_Number_Field__c} / 100 ) 


However when I try to output ${test} it just outputs the variable in the email instead of the result.


I've found that if I use the Velocity $math function, I can get it to work, but it's just so tedious for simple operations:


#set( $test = $math.div(${lead.Some_Number_Field__c},100 )) 


The above code does output a correct percentage (i.e. 35 => 0.35)


Anyone else have this experience?