Hello,
We are having trouble with an email using velocity script to display a field within a custom object. The field in the custom object contains a UUID which is needed to append to a link for a campaign we'll be running. We're using the velocity script token in the email link listed below. It appears as it's working when we send the email; however, when clicked, the email link takes us to a page stating an invitation is requested (used when there is no UUID matched to the database). But when opening the email in the browser and clicking the link, it then works and processes the page with the proper message. Why won't the link append the Program UID field as anticipated?
Link in Email: https://{{my.Email - CTA3_URL}}?offer=1&invitation={{my.Campaign UID}}
Velocity Script Token {{my.Campaign UID}} Details: ${cashBackVisa_cList.get(0).ProgramUID}
Field Name in Custom Object: Program UID
URL Shown from Email (random test): https://www.example.com/promotion?offer=1&invitation=${cashBackVisa_cList.get(0).ProgramUID}
URL Shown When the Same Email is Viewed in the Browser: https://www.example.com/promotion?offer=1&invitation=0736c113-669b-4043-9081-4a814eda08b8
(For security sake, I've made the beginning of the link an example)
There could be members who have more than one Program ID within this custom object. Not sure if this means anything when using velocity script.
Sanford Whiteman would you be able to help at all?
Thanks,
Raquel
Solved! Go to Solution.
You're using a real email, not a sample?
If it's a real email, have you tried recreating the token? I wonder if the token's link to the CO object has become corrupt (even if it's checked off in the tree in Script Editor). This happens sometimes.
Is there any way we can populate a custom lead field with the Program UID data that's in the custom object?
Not without some extremely complex development, and if what you're doing right now isn't working, that development couldn't work either.
There could be members who have more than one Program ID within this custom object. Not sure if this means anything when using velocity script.
It certainly does... when you use $list.get(0) -- or its clearer alternative, $list[0] -- you're getting the first record in the list. So you're using that first record's ProgramUID field, every time.
But that in itself isn't your problem. I suspect you're dealing with the different order-of-operations of Web View vs. Emails with regard to Velocity (which can be very confusing).
Try adding an empty check around the list (which you should always do anyway) and outputting this entire <a> from Velocity:
#if( !$cashBackVisa_cList.isEmpty() )
<a href="https://www.example.com?offer=1&invitation=${cashBackVisa_cList[0].ProgramUID}">Click here</a>
#end
Hi Sanford Whiteman,
Thanks for your quick response! I tried this and it seems to be having the same issue - once clicked, the email link doesn't work, but when clicking the email in the browser it processes the page with the proper message. Do you know why this is happening?
Email Click: https://www.example.com/promotion?offer=1&invitation=${cashBackVisa_cList.get(0).ProgramUID}&mkt_tok...
Browser Click: https://www.example.com/promotion?offer=1&invitation=0736c113-669b-4043-9081-4a814eda08b8
Is there any way we can populate a custom lead field with the Program UID data that's in the custom object? Of course, assuming we're going to use the first record's Program UID if members have more than one, and then include that lead field in the email link instead.
You're using a real email, not a sample?
If it's a real email, have you tried recreating the token? I wonder if the token's link to the CO object has become corrupt (even if it's checked off in the tree in Script Editor). This happens sometimes.
Is there any way we can populate a custom lead field with the Program UID data that's in the custom object?
Not without some extremely complex development, and if what you're doing right now isn't working, that development couldn't work either.
Sanford Whiteman IT WORKS! I was using a sample email with a lead's information. I've since recreated the velocity script token and added some styling to increase the font, make the link white, etc. ...and it works! Thank you so much!
As for pulling in the CO data into a lead field, that's highly disappointing but understandable. I wish Marketo made it easier to understand velocity scripting and accessing custom object data. Again, thank you!
OK, great. Yes, you can't use Samples to test Velocity unless the content is generated entirely within Velocity (i.e. no references to fields in the database... only local variables that you #set() in a Velocity token).
Sanford Whiteman Ah, that is understandable. Could you tell me what the stipulations are using the velocity script token to link an image? I tried doing this but kept getting a target="_blank"></a> text showing up. I tried recreating but not sure I did it correctly. Should it work using:
#if( !$cashBackVisa_cList.isEmpty() )
<a href="https://www.example.com/promotion?offer=1&invitation=${cashBackVisa_cList[0].ProgramUID}"></a>
#end
I tried a couple other ways, but none seemed to work.
There's no image in there, though.
Also please highlight code using the Advanced Editor's Syntax Highlighter: