How do I pass or access the default value for a custom my token?

Anonymous
Not applicable

How do I pass or access the default value for a custom my token?

I've constructed a custom my token that access a custom object.  But that object may not exist.  I'd like to just display a default that can be passed in just like all of the regular tokens, but nothing seems to work.  This is what I have in the email:

{{my.DisplayTitle:default=This is Default Title}}

However, the default here is never displayed.  Is there someway to access this in the token script or pass back an "undefined" to trigger the default?  The default seems to work fine with the standard tokens, but there doesn't seem to be a way to write your own token and show a default if nothing is defined.

Thanks!

Tags (1)
3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: How do I pass or access the default value for a custom my token?

That syntax doesn't work with Velocity tokens. But you can output a default value within the token. Yes, this means that having different defaults in different emails is annoying to set up.

Anonymous
Not applicable

Re: How do I pass or access the default value for a custom my token?

Thanks!  That's a bummer!  It would be great if you could pass in some form of argument. 

SanfordWhiteman
Level 10 - Community Moderator

Re: How do I pass or access the default value for a custom my token?

What I recommend is storing all strings in a separate token (a dictionary token, also used for language translations and such). Though it doesn't alleviate the need to include the dict at the email level if it's email-specific.

I have a blog post coming up on this topic... if you haven't already, check out my Velocity posts @ http://blog.teknkl.com/tag/velocity