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.
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
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
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!)
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
You still need to answer my Q above because I don’t know why you’re targeting this particular item in the list.
Using this as a format to render the text via velocity into the email and this works but the same process does not render the link - which is why asking you
Thanks,
Aditi
I think you’re jumping into a technical question.
My question is actually a business question: Why is the first/0-th item in your list of vMC items (whatever a “vMC” is, remember that has no meaning outside your company) the only item you want to output?
Assuming the list of vMCs isn’t sorted in any way (which you should) what do you see the first/0-th item as meaning, in business terms? Which item(s) does the business want to include in the email?
That’s not an answer, sorry. Not sure why you seem to be sidestepping my questions about your business logic.
Show the output of the line:
${vMC_cList}
Hi @SanfordWhiteman , @Darshil_Shah1
Answering your questions here:
your question 1 :
Show the output of the line:
${vMC_cList}
Answer 1 :
I got a long list of fields and their values from the Custom Object fields, some items are below :
help_url=url,
ImgURL=image link,
vis_metric1_img_url=image link,
op_body_text=text,
op_tip1_body_text=text
contact_url=url,
vis_metric2_text=12,
your question 2 :
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!)
Assuming the list of vMCs isn’t sorted in any way (which you should) what do you see the first/0-th item as meaning, in business terms? Which item(s) does the business want to include in the email?
Answer 2 :
The intent is not to output 0th-th item from a list at all. The intent is just to populate the link called through the velocity token in the email for all records that qualify for the email
To answer 2: should I only be using ${vMC_cList.get().op_tip1_cta_url} instead of ${vMC_cList.get(0).op_tip1_cta_url} - as don't intend to use the 0th item of any unordered list
If you could please elaborate on is sorting 100% necessary - the only intent is to output the link/text in an email from velocity tokens and if only changing to ${vMC_cList.get().op_tip1_cta_url} by removing (0) is enough.
Thank you