Re: My token inside of the URL not displaying values

deepikachandar
Level 1

Hi,

I'm fairly new to scripting - I'm trying to include a my token inside of my script. However, the data isn't populating. Apologies if this has already been asked previously.  

#set($equipmentName = ${my.equipment})
#set($WFID = ${my.WFID})
#set($urlBodyImage = "www.google.com/$WFID/body_image_$equipmentName")
    
<a href="https://${urlBodyImage}"><img alt="Image" style="background-color: #ffffff; display: block; float: none; margin: 0px auto; -ms-interpolation-mode: bicubic; padding: 0px;"https://www.dummyimage.com/255x100" width="255" /></a>

#end

The output I'm seeing is - https://www.google.com/$WFID/body_image_$equipmentName
How I want it to output - https://www.google.com/45689/body_image_iphone

 

Thanks! 

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

@deepikachandar please return to your thread and check responses.

SanfordWhiteman
Level 10 - Community Moderator

Much as I adore Velocity, I’d also wonder exactly why Velocity is being used here.

 

You can concatenate/interpolate {{my.tokens}} into URLs outside of Velocity, and it doesn’t look like you’re really manipulating the values (which would require Velocity)?

Jo_Pitts1
Level 10 - Community Advisor

@SanfordWhiteman wrote:

Much as I adore Velocity, I’d also wonder exactly why Velocity is being used here.

 

You can concatenate/interpolate {{my.tokens}} into URLs outside of Velocity, and it doesn’t look like you’re really manipulating the values (which would require Velocity)?


@SanfordWhiteman , my best guess is that there is more going on than meets the eye - the extra #end being the potential give away to me.

Jo_Pitts1
Level 10 - Community Advisor

@deepikachandar , 

I've edited your post to show your code as code.

There are a few problems that I can see.

  1. This line here #set($equipmentName = ${my.equipment}) doesn't need the {} around $my.equipment.  Ditto for the following line.
  2. However, your larger problem is that you can't directly access my tokens from within Velocity.  You can access object tokens (e.g. lead tokens), but not my tokens..  You'll need to use the defineburger method that was invented by @SanfordWhiteman (and used extensively by me).  If you search the nation you should find references to it.  If you need more however, let the hive mind know 🙂
  3. you seem to have an extra #end in your code.  I'm not sure if this is because you've only pasted a part of your script?

Cheers

Jo