Render token based off use or location, velocity/java help | Community
Skip to main content
February 3, 2017
Question

Render token based off use or location, velocity/java help

  • February 3, 2017
  • 1 reply
  • 2273 views

I have an email validator within a script token that appends a script to the end of the email template if it is in the preview but not on send. The issue I am having is that the token script does not render in the normal "view by: default", once I tie a lead to it via "view by: lead" the script runs fine, as expected with a script token. Can I somehow check the tokens attributes or context prior to rendering? I can get the context keys when viewing by lead or on send but how can I do it in the default preview?

I'd like to force this one script token to render my validator while in the default preview window.

simplified pseudo code since I don't know java:

#allowMeToCheckKeys()

#set ($thisSctiptTokensKeys = context.keys)

// Ideally $thisSctiptTokensKeys returns and array of objects with something like [location,my,etc...]

// then in location {where: 'default preview', render: false}

#if ($thisSctiptTokensKeys.location.where == "default preview")

     #context.put('location.render', true)

#end

Not sure if context is even the correct place to look in velocity templates but all I've found so far. Hope this explains what I'm looking to do. Any help or relevant documentation would be appreciated.

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 3, 2017

If you do Preview by List, the default view should be w/the first lead in the list.

February 3, 2017

Yeah, I could make a list named AA Validatior or something with one lead so it loads quickly. But like "view by lead", it is still a few extra steps for the user from the view default screen. Not the worst thing, but the more steps I can trim off, the better.

SanfordWhiteman
Level 10
February 4, 2017

Shouldn't be any extra steps. With the static list set, as soon as I click Preview the VTL is executed in the context of the first lead in the list.