SOLVED

Velocity Script not printing working hyperlink

Go to solution
RobinDijst
Level 1

Velocity Script not printing working hyperlink

I am having an issue with the following code:

 

 

##set the variable referrer to the last Marketo Form URL and set to lowercase
#set( $referrer = ${lead.anyvalue.toLowerCase()})

##check value
#if( $referrer.contains("abc"))
#set( $url = "www.abc.com")
#set( $name = "abc")

##second check
#elseif( $referrer.contains("xyz"))
#set( $url = "www.xyz.com")
#set( $name ="xyz")

##fallback
#else
#set( $url = "www.foo.com")
#set( $name ="foo")

#end

##print Outcome
<a href="https://$url">$name</a>

 

 

 

So the code works in basis.

The $name variable works and displays as expected in all cases. The url doesn't work. But only doens't work for the dependent values, the fallback value always shows.

 

After some testing, I found that if I take the $url out of the href tag and paste them as seperate lines, it works just fine. But, whenever I try to add it to the href tag, it breaks. The output is like this on the URL:

https://%24url/?mkt_tok=tokenhere

 

Hope anyone can help me out on this because it's driving me nuts. Looking at the documentation (and forum) this should work but clearly doesn't.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Michael_Florin
Level 10

Re: Velocity Script not printing working hyperlink

Have you tried using formal notation? Looking at my script library, I believe that's what Sanford taught us all to do. 🙂

<a href="https://${OutputURL}">Click here</a>



View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script not printing working hyperlink

What Michael said. But also your first line should be using simple notation:

#set( $referrer = $lead.anyvalue.toLowerCase() )

 

Use simple notation when calling methods. Use formal notation when creating output or interpolating strings.

View solution in original post

3 REPLIES 3
Michael_Florin
Level 10

Re: Velocity Script not printing working hyperlink

Have you tried using formal notation? Looking at my script library, I believe that's what Sanford taught us all to do. 🙂

<a href="https://${OutputURL}">Click here</a>



RobinDijst
Level 1

Re: Velocity Script not printing working hyperlink

Thanks to both. This works like a charm!

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script not printing working hyperlink

What Michael said. But also your first line should be using simple notation:

#set( $referrer = $lead.anyvalue.toLowerCase() )

 

Use simple notation when calling methods. Use formal notation when creating output or interpolating strings.