Struggling with Velocity Script token - Please Help! | Community
Skip to main content
New Participant
May 21, 2024
Question

Struggling with Velocity Script token - Please Help!

  • May 21, 2024
  • 2 replies
  • 907 views

Hello Community,

 

I've been trying to create a velocity script token that will output a clickable URL that contains lead token data but replace certain lead token data with "-99" if the tokens are empty.

 

This is what the URL normally looks like when we use it in email:

http://{{lead.Cruise GoTo URL}}&member_id={{lead.member id}}&name_id={{lead.name id}}&cruiseLineId={{lead.Cruise Line Code}}&cruiseDestinationId={{Lead.Cruise Destination Code}}&sort=4&ls=cruises/promos/new/cruise_search.jsp

 

However, not all tokens will be populated with data, specifically the "Cruise Line Code" and "Cruise Destination Code".

 

I've been trying to use this script below, but to no avail 😥  Of course the team is requesting this at the ninth hour and I'm scrambling to build it.

 

Does anyone have any suggestions?

 

#set( $cruiseGoToURL = $lead.cruiseURL) #set( $memberId = $lead.memberId ) #set( $nameId = $lead.nameId ) #set( $cruiseLineCode = $lead.cruiseLineCode ) #set( $cruiseDestinationCode = $lead.cruiseDestinationCode ) #if( $cruiseLineCode.isEmpty() ) #set( $cruiseLineCode = "-99" ) #end #if( $cruiseDestinationCode.isEmpty() ) #set( $cruiseDestinationCode = "-99" ) #end #set( $url = "http://${cruiseGoToURL}&member_id=${memberId}&name_id=${nameId}&cruiseLineId=${cruiseLineCode}&cruiseDestinationId=${cruiseDestinationCode}&sort=4&ls=cruises/promos/new/cruise_search.jsp" ) <a href="${url}">${url}</a>


 

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

2 replies

Jo_Pitts1
Community Manager
May 21, 2024

@guitarrista82 ,

In addition to @sanfordwhiteman's points:

  1. What is the output you are getting vs. expected output?
  2. Have you checked off all the lead fields in the tree on the RHS?

Cheers

 

SanfordWhiteman
New Participant
May 21, 2024

Missing some crucial info here. What are some sample values stored in the cruiseURLfield? What outcome are you seeing?

 

There’s nothing syntactically wrong with your code but of course that’s only the first thing that can go wrong.