Velocity token to populate link based on lead record value | Community
Skip to main content
Travis_Schwartz
Level 4
July 28, 2022
Solved

Velocity token to populate link based on lead record value

  • July 28, 2022
  • 1 reply
  • 4309 views

I'm hoping I can use velocity to populate a link instead of using traditional segmentation or creating multiple versions of emails.

 

I have a link that I need to show, but the link is going to be reliant on the value in a certain field in the lead record.

 

The value I am using to populate the field is ${lead.creditCardPromoAmount}

 

What I need it to do is

 

 

If $lead.creditCardPromoAmount = 15,000 then display this unique url elseIf $lead.creditCardPromoAmount = 7,500 then display this unique url elseIf $lead.creditCardPromoAmount = 5,000 then display this unique url elseIf $lead.creditCardPromoAmount = 2,500 then display this unique url

 

 

Those are the only possible values that members of this program will have.

 

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 Darshil_Shah1

In general and per my understanding, equals() is more robust than the == operator for comparing data.

 

#if ($lead.creditCardPromoAmount.equals("15000")) <a href="https://www.example.com/link1">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("7500")) <a href="https://www.example.com/link2">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("5000")) <a href="https://www.example.com/link3">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("2500")) <a href="https://www.example.com/link4">Account Opening Disclosure</a> #end

 

It is recommended to not use the == operator to compare two values because it checks the equality of the reference whereas, the equals function checks the values.

 

1 reply

Travis_Schwartz
Level 4
July 28, 2022

Would something like this work?

 

 

#if ( $lead.creditCardPromoAmount == 15000 ) <a href="link1">Account Opening Disclosure</a> #elseif ( $lead.creditCardPromoAmount == 7500 ) <a href="link2">Account Opening Disclosure</a> #elseif ( $lead.creditCardPromoAmount == 5000 ) <a href="link3">Account Opening Disclosure</a> #elseif ( $lead.creditCardPromoAmount == 2500 ) <a href="link4">Account Opening Disclosure</a> #end

 

 

 

Darshil_Shah1
Community Advisor and Adobe Champion
Darshil_Shah1Community Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
July 29, 2022

In general and per my understanding, equals() is more robust than the == operator for comparing data.

 

#if ($lead.creditCardPromoAmount.equals("15000")) <a href="https://www.example.com/link1">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("7500")) <a href="https://www.example.com/link2">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("5000")) <a href="https://www.example.com/link3">Account Opening Disclosure</a> #elseif ($lead.creditCardPromoAmount.equals("2500")) <a href="https://www.example.com/link4">Account Opening Disclosure</a> #end

 

It is recommended to not use the == operator to compare two values because it checks the equality of the reference whereas, the equals function checks the values.

 

SanfordWhiteman
Level 10
July 29, 2022

Like Darshil says, use .equals(), not ==.

 

The reason isn't reference equality vs. value equality, though. It's that == type-juggles both sides which can lead to unexpected, even business-incorrect results. .equals() is standard Java, which has predictable, well-documented results.