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

Anonymous
Not applicable

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

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.

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

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

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

Anonymous
Not applicable

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

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 - Community Moderator

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

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.

Anonymous
Not applicable

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

How are you setting the static list to be default when clicking preview? I can set it in the preview window but as soon as I edit the email or leave the preview it does back to "view by default". If you can set a static list to be the default preview globally, that would be amazing!

SanfordWhiteman
Level 10 - Community Moderator

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

Huh... for me, it's always been sticky this way. Maybe try to unset and reset it a couple of times?  And try with a new user to see if your profile is corrupt somehow.

Anonymous
Not applicable

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

Tried as another user, in sandbox, and had someone in another instance check, no sticky behavior. I think you might have a *feature* I want. Looked through setting too to see if there was an option for this behavior but did not see anything.