Troubles when using Javascript within Velocity? | Community
Skip to main content
Level 2
August 8, 2019
Question

Troubles when using Javascript within Velocity?

  • August 8, 2019
  • 1 reply
  • 5401 views

I've been trying to implement @Sanford Whiteman‌'s post "Use Javascript within Velocity" from late 2017 to utilize Javascript in an Email Script Token, and when following the example verbatim, instead of outputting the Lead's firstname

Kenneth

playfully as

K e N n E t H

, the actual Velocity code is output in the email:

$JSEngine.put("lead", $lead) $JSEngine.get("spacedOutInJS")

Attached are screenshots showing:

  • the token script - named "ai_trk_test" (20190808_104120_msedge_CompassionateTuraco_938x794.png),
  • the email draft with {{my.ai_trk_test}} included (20190808_104357_msedge_SnowBuzzard_815x516.png), and
  • previewing the email as a Person with Kenneth as first name 20190808_104600_msedge_ImmenseBluet_1052x680.png)

Am I missing something here?

Kenneth Soldink

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

1 reply

Level 2
August 8, 2019

Just came across this https://nation.marketo.com/docs/DOC-6953 which probably means that this is not supported anymore...

SanfordWhiteman
Level 10
August 8, 2019

Correct, this and many other advanced techniques were disabled at that time. 

In fairness, though, this is more of a frill (as opposed to other important techniques that have no equivalent now). What exactly are you trying to do with your data that required JS?

Level 2
August 12, 2019

I was originally aiming to generate a Base64 string from small JSON string that contains some default and custom fields, as well as a timestamp, to append onto links. I can go a different route, but this was nice as it afforded my endpoint some simplicity in interpreting the string.