...
Solved! Go to Solution.
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.
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
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,
Nothing is gained by obfuscating your data to this degree. We want to see the type of value stored in your fields, since those fields may be used to filter the list.
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} -
List.get() has no meaning. It’s a fatal error. List.get(n) gets the n-th item in a list. You must choose an item. Again, we assume you do not want a random item.
Think about this real world example:
You have a closet full of an unknown number of shirts. You want to pick out a shirt to wear to a specific event. You know how to pick one shirt at random from your closet. Are you ready to go to that event? Does it not matter which shirt you choose?
A person record can have multiple custom object records associated with it, of all of those which CO record would you like to be considered for populating the URL? I suppose you won’t output links present in all the custom object records in vMC_cList, right? Also removing the index argument from the get function isn’t enough. You’ll run into an error. Ideally, we should first sort the list of CO records in the required order and then grab the correct CO record for populating the data based on it in the email. If you’re still unclear, do you want to hop on a call to discuss this? I think that would be better and faster instead of exchanging comments here?
Thanks very much @Darshil_Shah1 yes, this will indeed be more clear then