Custom Token Not Working Sometime | Community
Skip to main content
Eben_Saputra
Level 3
February 27, 2019
Question

Custom Token Not Working Sometime

  • February 27, 2019
  • 1 reply
  • 5297 views

Hi there,

We personalize our email footer based on the Clinic ID of patient

The way we do this is by implementing a Global token (called my.global) as storage for information

Then we use Clinic ID as lookup value to get other data

This is a snippet of the value that we have

My.Global

","latitude":51.112309,"Longitude":-114.212415,"GetDirections":"www.google.com/maps/dir/Lifemark Crowchild Twin Arena+Crowchild Twin Arenas+Calgary+Alberta+T3L 1L4"},"313656":{"ClinicId":10159,"LPSClinicId":313656,"OfficialName":"Lifemark Sport - Canada Games Centre","Address1":"Suite 182","City":"Halifax","Province":"Nova Scotia","PostalCode":"B3S 0E2","Telephone":"(902) 404-3888","Email":"info.cgc@lifemark.ca","ParkingAndTransportation":"The clinic is wheelchair accessible. The newly expanded parking lot provides extensive free parking. If you have an injury or want to prevent future injuries, please call us now to schedule an appointment.

Now here comes the problem.

Only some of the token works

Clinic Name token never works

Clinic Name

Token Code

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

##if clinic id found

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

$clinics.Map.get($clinicID).OfficialName

#end

But Clinic Address always work

Clinic Address

Token Code

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

##if clinic id found

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

$clinics.Map.get($clinicID).Address1

#end

We actually used this technique before for other email journey and it was working without problem

Any thoughts why this doesn't work?

My.Global
","latitude":51.112309,"Longitude":-114.212415,"GetDirections":"www.google.com/maps/dir/Lifemark Crowchild Twin Arena+Crowchild Twin Arenas+Calgary+Alberta+T3L 1L4"},"313656":{"ClinicId":10159,"LPSClinicId":313656,"OfficialName":"Lifemark Sport - Canada Games Centre","Address1":"Suite 182","City":"Halifax","Province":"Nova Scotia","PostalCode":"B3S 0E2","Telephone":"(902) 404-3888","Email":"info.cgc@lifemark.ca","ParkingAndTransportation":"The clinic is wheelchair accessible. The newly expanded parking lot provides extensive free parking. If you have an injury or want to prevent future injuries, please call us now to schedule an appointment.

Clinic Name#set($clinicID = ${lead.ClinicID})##if clinic id found#if($clinics.Map.get($clinicID))$clinics.Map.get($clinicID).OfficialName#end
Clinic Address#set($clinicID = ${lead.ClinicID})##if clinic id found#if($clinics.Map.get($clinicID))$clinics.Map.get($clinicID).Address1#end

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
February 27, 2019

Please go back in and highlight the code so it's readable.

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

Also, you shouldn't use ${formal} references in #set statements, use $simple to avoid syntax errors.

While you haven't published enough of your code, if this is the definition of $clinics:

#set( $clinics = {

"Map" : {

"313656" : {

"ClinicId" : 10159,

"LPSClinicId" : 313656,

"OfficialName" : "Lifemark Sport - Canada Games Centre",

"Address1" : "Suite 182"

}

}

} )

And $lead.ClinicID is a String (not Integer) with the value "313656" then there's no reason that both properties will not be found:

#set($clinicID = $lead.ClinicID)

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

$clinics.Map.get($clinicID).OfficialName

#end

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

$clinics.Map.get($clinicID).Address1

#end

Eben_Saputra
Level 3
February 27, 2019

I tried putting erasing {} but it doesn't solve the problem.

Actually it was never a problem

Question : Is there a certain formatting condition that might cause token value to not be summoned?

Typically when using custom token, the display will be empty only if there is no data to display (or coding error, but we rule that out)

But in my case, when I use blank template ​the token will show up just fine

When I use this custom email template, then value stops showing for ClinicName

Newsletter - Google Docs

What is also curious, if I put this token side by side with other token, suddenly both token shows value

I suspect there might be some Marketo bug, so I

1. Clone to another campaign that has similar global token

2. Copy and use another token

3. Delete the email and copy new one

But same thing happens. The blanks shows value, but not the template.

Pretty much at wit's end here

SanfordWhiteman
Level 10
February 28, 2019

I tried putting erasing {} but it doesn't solve the problem.

Didn't say it was the cause in this case, but formal references cause syntax errors soon as you chain methods, which is why they should be avoided.

#set( $something = $reference.toUpperCase() ) ## no error

#set( $something = ${reference}.toUpperCase() ) ## error

When I use this custom email template, then value stops showing for ClinicName

Newsletter - Google Docs

What is also curious, if I put this token side by side with other token, suddenly both token shows value

Hmm... doesn't make much sense.

Are you including the tokens in exactly the same order in both cases (doesn't look like it from the links)?


What about in a plain-text email? Are you positive there isn't an HTML structural error that's causing something to be hidden (but in fact output in the HTML)?