Skip to main content
Travis_Schwartz
Level 4
Jul 28, 2022 11:17 PM UTC
Solved

Velocity token to populate link based on lead record value

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.
Darshil_Shah1
Darshil_Shah1Accepted solution
Adobe Champion, Community Advisor, UG Leader
Jul 29, 2022 2:56 AM UTC

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.

 

12 replies

Travis_Schwartz
Level 4
Jul 28, 2022 11:35 PM UTC

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

 

 

 

Translate
Darshil_Shah1
Adobe Champion, Community Advisor, UG Leader
Darshil_Shah1Adobe Champion, Community Advisor, UG LeaderAccepted solution
Adobe Champion, Community Advisor, UG Leader
Jul 29, 2022 2:56 AM UTC

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.

 

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Jul 29, 2022 3:30 AM UTC

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.

Translate