Velocity Script Using Custom Object Not Appending When Email Is Sent | Community
Skip to main content
Raquel_Babb
Level 2
July 11, 2018
Solved

Velocity Script Using Custom Object Not Appending When Email Is Sent

  • July 11, 2018
  • 1 reply
  • 5711 views

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: {{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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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.

1 reply

SanfordWhiteman
Level 10
July 11, 2018

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

Raquel_Babb
Level 2
July 12, 2018

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=eyJpIjoiTkd...

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.

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
July 12, 2018

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.