Re: Struggling with Velocity Script token - Please Help!

Guitarrista82
Level 6

Struggling with Velocity Script token - Please Help!

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>


 

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Struggling with Velocity Script token - Please Help!

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.

Jo_Pitts1
Level 10 - Community Advisor

Re: Struggling with Velocity Script token - Please Help!

@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