Random Glitches When Pulling Email | Community
Skip to main content
Eben_Saputra
Level 3
July 26, 2018
Question

Random Glitches When Pulling Email

  • July 26, 2018
  • 1 reply
  • 2560 views

We are having an issue with email script tokens, we add an object value to the custom token and are finding that randomly that value won’t print / doesn’t have a value. This occurs without any changes made to the email script.

Some other time, the <h2>$clinics.Map.get($clinicID).OfficialName</h2> part of the token is treated just like ordinary string, and you see the code written bare on the email

#set($clinicID = ${lead.recentlyCreateClinicID})

The Clinic ID: ${lead.recentlyCreateClinicID}

<br>

The Clinic parsed: ${clinicID}

<br>

##if clinic id found

#if($clinics.Map.get($clinicID))

<h2>$clinics.Map.get($clinicID).OfficialName</h2>

#end

It has nothing to do with the global token thing we did, it’s just pulling from custom object.

When it is acting up, sending it to email will also show how it looks like on preview mode.

When it is not acting up , sending to email will also nice and proper email, without the weird code written bare

Any thoughts?

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

1 reply

SanfordWhiteman
Level 10
July 26, 2018

I doubt it's actually random. Velocity's behavior is to print source code if there's a handled exception. ​It only throws explicit errors w/error messages on ​unhandled exceptions. ​But both are error cases.

What is this $clinics.Map property?  That nomenclature wouldn't be the usual way Marketo exports a CO list into Velocity. And if that reference is broken because the property Map doesn't exist you'll see just the source code.  (Compare to what happens if $clinics.Map itself exists and is an array/list, but the indexed property $clinics.Map[<integer>] doesn't exist -- in contrast that's a hard error that will explicitly tell you there was a nonexistent index.)

July 26, 2018

Hi,

So the problem is that ${lead.recentlyCreateClinicID} will suddenly not have a value, we will have just this field printing on the page, and it will come up with nothing. We will work around a bit and then without a code change it comes back.

When this happens it causes the error where the token is printed to the screen.

$clinics is a global variable in JSON format. This is how we are pulling from a token with all our content. As long as ${lead.recentlyCreateClinicID} has a value everything works properly.

SanfordWhiteman
Level 10
July 26, 2018

So the problem is that ${lead.recentlyCreateClinicID} will suddenly not have a value

Suddenly not have a value, or suddenly not be a key on the $lead object?


What does $lead.containsKey("recentlyCreateClinicID") print in these circumstances?

What does the lead token {{lead.Recently Create Clinic ID}} (use the real token name, of course) print if you include it in the same email (outside of Velocity, of course)?

Are you testing only using real emails (you can't use Samples to test Velocity)?