Tokenized links rendering correctly on preview but not on real email
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:
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!