Tokenized links rendering correctly on preview but not on real email | Community
Skip to main content
Victor_Herrero
New Participant
September 23, 2020
Solved

Tokenized links rendering correctly on preview but not on real email

  • September 23, 2020
  • 1 reply
  • 3044 views

 

 

Hi, 

 

I have been having an issue with links in some of our emails. The link contains an important parameter for an id that can be in two different fields but i don't know which, so I check both in the script token and get the first non-empty match. 

 

The link inside the email looks like this: 

{{my.ar_referral_url}}?ls=Referral&lsd=Au+Pair+Referral&utm_source=Referral&utm_medium=Email&utm_campaign=AR_direct+referral_AR+Referral+Campaign_PreDeparture&apid={{my.aupairID_master}}&reftype=Aupair&sfc=7013q000001kOgt&sfcs=Responded

 

 

The script token looks like this: 

 

## Returns the first populated Au Pair Id / Au pair ## from either the Lead, Contact, Account or Opportunity objects ## ## ## Define possible variables ## // Au Pair Number should be used instead of Au Pair ID, ## // since Au Pair ID can be different in Tellus sometimes #set($AupairNumber = "initial value") #set($empty = "") ## ## Determine the first not empty value #if(${lead.AP_Au_Pair_Number__c} != $empty) #set($AupairNumber=${lead.AP_Au_Pair_Number__c}) #elseif(${company.AP_Au_Pair_Number__c} != $empty) #set($AupairNumber=${lead.Au_pair_number__c}) #elseif(${OpportunityList.get(0).Au_Pair__c} != $empty) #set($AupairNumber=${OpportunityList.get(0).Au_Pair__c}) #else #set($AupairNumber = "unknown") #end ## ## Return not empty value $AupairNumber

 

 

And in preview renders correctly (valid url and 'apid' correclty rendered): 

But the real email either redirects to this in gmail when I click, before I replaced the first regular token with a splled-out url (url invalid)

 

Or this after replacing the initial regular token (url valid but 'apid' is now empty)

 

Any insights into why this is happening? I deactivated link tracking as well for this link, since I already noticed that breaks links with script tokens 
Perhaps you @sanfordwhiteman ?

 

Thanks!

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 SanfordWhiteman

Shouldn't compare to empty (nor use the == operator at all!) but rather use isEmpty():

## Returns the first populated Au Pair Id / Au pair ## from either the Lead, Contact, Account or Opportunity objects ## ## ## Define possible variables ## // Au Pair Number should be used instead of Au Pair ID, ## // since Au Pair ID can be different in Tellus sometimes #set($AupairNumber = "initial value") ## ## Determine the first not empty value #if( $lead.AP_Au_Pair_Number__c.isEmpty() ) #set( $AupairNumber = $lead.AP_Au_Pair_Number__c ) #elseif( $company.AP_Au_Pair_Number__c.isEmpty() ) #set( $AupairNumber = $lead.Au_pair_number__c ) #elseif( $OpportunityList.get(0).isEmpty() ) #set( $AupairNumber = $OpportunityList.get(0).Au_Pair__c ) #else #set( $AupairNumber = "unknown" ) #end ## ## Return not empty value $AupairNumber

 

But that's not the problem — the prob is you must output the entire link, from <a> through </a> inclusive from Velocity. Links made partially from Velocity output aren't aren't supported.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
September 23, 2020

Shouldn't compare to empty (nor use the == operator at all!) but rather use isEmpty():

## Returns the first populated Au Pair Id / Au pair ## from either the Lead, Contact, Account or Opportunity objects ## ## ## Define possible variables ## // Au Pair Number should be used instead of Au Pair ID, ## // since Au Pair ID can be different in Tellus sometimes #set($AupairNumber = "initial value") ## ## Determine the first not empty value #if( $lead.AP_Au_Pair_Number__c.isEmpty() ) #set( $AupairNumber = $lead.AP_Au_Pair_Number__c ) #elseif( $company.AP_Au_Pair_Number__c.isEmpty() ) #set( $AupairNumber = $lead.Au_pair_number__c ) #elseif( $OpportunityList.get(0).isEmpty() ) #set( $AupairNumber = $OpportunityList.get(0).Au_Pair__c ) #else #set( $AupairNumber = "unknown" ) #end ## ## Return not empty value $AupairNumber

 

But that's not the problem — the prob is you must output the entire link, from <a> through </a> inclusive from Velocity. Links made partially from Velocity output aren't aren't supported.

Victor_Herrero
New Participant
September 23, 2020

Thanks so much for going over it Sanford! 

I'll redo things according to your feedback and see.