Velocity script link is getting "%0D" added at the end breaking the link

maddie_jtf
Level 2

Velocity script link is getting "%0D" added at the end breaking the link

Hi everyone, 

 

I have the following situation: I'm using a very simple Velocity script in an email to display a link to a different landing page depending on which course someone completed. We also have UTM parameters added to the links in an email using a variable at template level.

 

The script is working - as in it's pushing the correct link. The problem is that the link in the email is seemingly broken and redirects me to the website's homepage, as there's %0D added between the link and the UTM parameters.  I can't figure out where the extra characters are coming from - I've checked the template and there's nothing in there, plus other emails without the Velocity script work fine. 

 

The script I'm using is:

#if (${lead.Training_Expert_Complete__c}=="1")
https://info.jtfmarketing.co/Post-Training-Survey-Expert.html
#else
https://info.jtfmarketing.co/training-evaluation.html
#end  

 

I'd appreciate any support you could provide.

 

Thanks,

Maddie

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script link is getting "%0D" added at the end breaking the link

Few things here.

 

No need for the formal references ({}) — those will only cause confusion. And the == operator is buggy in some hard-to-detect ways, so always use .equals().

#if( $lead.Training_Expert_Complete__c.equals("1") )
https://info.jtfmarketing.co/Post-Training-Survey-Expert.html
#else
https://info.jtfmarketing.co/training-evaluation.html
#end  

 

Now, those aren't contributing to this particular case. What you're actually seeing is exactly what you're typing: you have a line break at the end of those lines. That's a %0D.  You can suppress it:

#if( $lead.Training_Expert_Complete__c.equals("1") )
https://info.jtfmarketing.co/Post-Training-Survey-Expert.html##
#else
https://info.jtfmarketing.co/training-evaluation.html##
#end  

 

But this is likely to disrupt processing, and is not recommended, because there's another more fundamental problem: the entire link should be output from Velocity. That is, the <a> through the </a> should all come from the Velocity token. This is the only supported method to get tracked & intact links.