Velocity Scripting an Equation | Community
Skip to main content
Jul 14, 2017 9:07 PM UTC
Solved

Velocity Scripting an Equation

Hi all,

We want to show our leads how much they could save for a certain transaction. The transaction is a custom object field and I believe this can be done with velocity scripting but am unsure of what tool to be using.

Example: Lead custom object field is $500 want to show a 5% savings ($25).

I'm new to email scripting so thank you in advance!!!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jul 14, 2017 9:30 PM UTC

You have to know more about how your CO is set up to know exactly how to fit this for your situation, but for a generic CO Product with the numeric field Price, the approach is like this:

#if( !$Product__cList.isEmpty() )

#set( $firstProductPrice = $Product__cList[0].Price )

#set( $savingsAmount = $math.mul($firstProductPrice, .05) )

#set( $discountedPrice = $math.sub($firstProductPrice, $savingsAmount) )

Pay only ${number.currency($discountedPrice)}!

That's ${number.currency($savingsAmount)}

under the regular price of ${number.currency($firstProductPrice)}!

#end

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jul 14, 2017 9:30 PM UTC

You have to know more about how your CO is set up to know exactly how to fit this for your situation, but for a generic CO Product with the numeric field Price, the approach is like this:

#if( !$Product__cList.isEmpty() )

#set( $firstProductPrice = $Product__cList[0].Price )

#set( $savingsAmount = $math.mul($firstProductPrice, .05) )

#set( $discountedPrice = $math.sub($firstProductPrice, $savingsAmount) )

Pay only ${number.currency($discountedPrice)}!

That's ${number.currency($savingsAmount)}

under the regular price of ${number.currency($firstProductPrice)}!

#end

Translate
Jul 14, 2017 10:13 PM UTC

Thank you!

Translate