SOLVED

Velocity token to populate link based on lead record value

Go to solution
Travis_Schwartz
Level 4

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Velocity token to populate link based on lead record value

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.

 

View solution in original post

12 REPLIES 12
Travis_Schwartz
Level 4

Re: Velocity token to populate link based on lead record value

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
Level 10 - Community Advisor + Adobe Champion

Re: Velocity token to populate link based on lead record value

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 - Community Moderator

Re: Velocity token to populate link based on lead record value

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.

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Velocity token to populate link based on lead record value

Ahh - gotcha! Thank you, Sandy! 🙂

 

Travis_Schwartz
Level 4

Re: Velocity token to populate link based on lead record value

Thank you!

Travis_Schwartz
Level 4

Re: Velocity token to populate link based on lead record value

So I've updated this token and I'm getting the following result:

 

Screen Shot 2022-08-05 at 12.24.57 PM.png

But when I preview the email with someone who qualifies, every time I get this result:

Screen Shot 2022-08-05 at 12.24.43 PM.png

 

I have used the script exactly as outlined (except for adding the unique url for each group):

 

#if ($lead.creditCardPromoAmount.equals("15000"))
<a href="https://arrow17.secure.cusolutionsgroup.net/files/arrow17/1/file/Interstitials/08%202022%20Visa%20PA_InterstitialDIsc_02.pdf">Account Opening Disclosure</a>
#elseif ($lead.creditCardPromoAmount.equals("7500"))
<a href="https://arrow17.secure.cusolutionsgroup.net/files/arrow17/1/file/Interstitials/08%202022%20Visa%20PA_InterstitialDIsc_04.pdf">Account Opening Disclosure</a>
#elseif ($lead.creditCardPromoAmount.equals("5000"))
<a href="https://arrow17.secure.cusolutionsgroup.net/files/arrow17/1/file/Interstitials/08%202022%20Visa%20PA_InterstitialDIsc_06.pdf">Account Opening Disclosure</a>
#elseif ($lead.creditCardPromoAmount.equals("2500"))
<a href="https://arrow17.secure.cusolutionsgroup.net/files/arrow17/1/file/Interstitials/08%202022%20Visa%20PA_InterstitialDIsc_08.pdf">Account Opening Disclosure</a>
#end

 

And I've made sure the check mark is on the ${lead.creditCardPromoAmount} field.

 

Any idea why there would be no value displaying?

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Velocity token to populate link based on lead record value

Well, you do not have a catch-all #else statement in your script, which means that if a person has a value other than the ones mentioned in the #if #elseif conditional statements, they'd not be shown any output (as they'd not qualify for any of the defined conditions). Does your test lead have Credit Card Promo Amount value other than "15000", "7500", "5000", or "2500"? Also, if this is a string field, and if you have "," chars in the value (e.g., "15,000" instead of "15000"), then also it won't work.

 

Travis_Schwartz
Level 4

Re: Velocity token to populate link based on lead record value

I've tested multiple accounts with 1500 and 7500 and got the same result shown above.

 

Here is the field in a record I attempted:

 

Screen Shot 2022-08-05 at 3.28.55 PM.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token to populate link based on lead record value

Please show the output of

${lead.creditCardPromoAmount.class}