Re: URL Not Resolving in Email Script Token | Community
Skip to main content
adanand
Level 2
June 12, 2023
Solved

Re: URL Not Resolving in Email Script Token

  • June 12, 2023
  • 1 reply
  • 5731 views

...

Best answer by Darshil_Shah1

Hello @adanand, custom objects are stored in descending order of their created date. So the first custom object in the CO list would be the one that was added last, usually in almost all of the cases this does not get us anywhere, and hence we first sort the custom object list per our requirement (e.g., sort by updated date, a field, etc.) and then start working with the records in it (as once sorted we'd know the order of records in it). Additionally, are you assuming that a custom object can only contain 1 record? If so that's not true, a CO can contain n number of records, all of which together make a custom object list. Also, after sorting we aren't gonna grab the entire list, just the relevant field from a particular CO record.

 

Furthermore, what we mean by outputting the complete <a> through </a> is that you need to have something like the below in your velocity script (of course after doing the necessary sorting first):

 

<a href="https://${vMC_cList.get(0).performance_cta_url}?utm_medium=paid-social&utm_source=linkedin&utm_campaign=ABC_Test">Click here</a>

 

You can't just output just the URL from the CO field from a velocity token, then reference it in the email's link editor. You have to output the fully formed <a> tag from the velocity script itself.

 

I hope this is useful. Pls let us know if you have questions.

 

1 reply

adanand
adanandAuthor
Level 2
June 12, 2023

 

Hi @Darshil_Shah1 ,

 

The link we are sending to the Custom Object does not have https://

 

We have the protocol in the email body: href="https://{{my.VMC-PERFORMANCE-CTA-URL}}{{my.cta1-URLparams}}"

 

The velocity script token is : ${vMC_cList.get(0).performance_cta_url}

 

When I test the link: it is not picking up the performance_cta_url token value - it is literally pasting performance_cta_url token name in the link url as below

 

%24%7Bvmc_clist.get%280%29.performance_cta_url%7D%26utm_source%3Dmarketo%26utm_medium%3Demail%26utm_campaign%3Dmid_6118%26utm_content%3Dna%26utm_term%3Dadvanced_email/?mkt_tok=NDQzLVlZUS00MTAAAAGMUMsyrflNKSVevf00_j0EoqNnT3ZzGoqqSjZPZ6xwUn2scIRna2c4t3zwS2pMIr7kVIVU_dYVjqdUKPhGKA0

 

I am not a velocity expert, but I need to get this link to work - is there no way to edit the above velocity token (without looping) just a simple direct way to get this link to work?

 

Many thanks

SanfordWhiteman
Level 10
June 13, 2023

You cannot create links like that. As noted elsewhere, the entire link needs to be output from Velocity.

 

That means the opening <a> through closing </a> is coming from your token. You can’t have some of the link outside of your token, and some of the link inside.

 

However, that’s only part of the problem. You’re also trying to output what looks like one arbitrary item: the first/0-th item in the list. Why is that — is there something special about the first item in an arbitrarily ordered list? (Hint: probably not!)

adanand
adanandAuthor
Level 2
June 13, 2023

Hi @sanfordwhiteman 

Thanks for your response

Are you please able to share how to edit this velocity script token is : ${vMC_cList.get(0).performance_cta_url} 

 

to meet the condition below

 

That means the opening <a> through closing </a> is coming from your token. You can’t have some of the link outside of your token, and some of the link inside. 

 

I am not a velocity expert and will appreciate if you can please share the answer here

 

Thanks,

Aditi