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>
Missing some crucial info here. What are some sample values stored in the cruiseURL
field? 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.
In addition to @SanfordWhiteman's points:
Cheers