Re: How to cancel characters on a URL velocity token

Maria_Riley1
Level 2

How to cancel characters on a URL velocity token

Hi, 

I have a URL on a token that contains an invalid character "-" how do I cancel the character for Velocity to recognize the last part of the URL?

https://zoom.us/meeting/register/up0kc-mspz8tti8FToCZWpyiF-3JZvOTFg

thanks

Maria

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: How to cancel characters on a URL velocity token

Let's not use the word "cancel," that doesn't mean anything in the world of string processing.

 

I don't understand what you mean by invalid. A hyphen is totally valid in a URL. What do you want Velocity to do with this value... what's the input, what's the output?

Maria_Riley1
Level 2

Re: How to cancel characters on a URL velocity token

Hi,

We have the token below which has worked in the past with previous URLs. 

It populates the URL for a link. 

However, it is not working now. 

I believe, Velocity is not recognizing the  -  as a part of the url.  It seems to happens only when - is followed by a number.  

On the edit script token window, all the URL after the - is in red and not blue.

 

#if( !$$Course_Enrollment__cList.isEmpty() )
#foreach($reg in $Course_Enrollment__cList )
#if( $reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 21-4-2020(closed cohort) - 2020-04-21" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/tJAufuuopjkqGdVaZp2Uf7CHlTtGrJipbYV6
#elseif($reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 21-4-2020 - 2020-04-21" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/tJcuduqsqDgpHNJ_5KQ-6tqw4fwH8B6IyAuy
#elseif( $reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 28-4-2020 - 2020-04-28" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/uJEsc-2grj4oNEti0ZKoGUHugUzKKPCjDw
#else
#end
#end
#end
#end

 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to cancel characters on a URL velocity token

There's one too many #end statements there,  and also an extra $ before $Course_Enrollment_cList.isEmpty().

 

The syntactically valid code would be:

 

#if( !$Course_Enrollment__cList.isEmpty() )
#foreach($reg in $Course_Enrollment__cList )
#if( $reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 21-4-2020(closed cohort) - 2020-04-21" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/tJAufuuopjkqGdVaZp2Uf7CHlTtGrJipbYV6
#elseif($reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 21-4-2020 - 2020-04-21" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/tJcuduqsqDgpHNJ_5KQ-6tqw4fwH8B6IyAuy
#elseif( $reg.Netsuite_Description__c =="Addressing Difficult Behaviours ON 28-4-2020 - 2020-04-28" && $reg.Course_Enrollment_Status__c =="Enrolled")https://zoom.us/meeting/register/uJEsc-2grj4oNEti0ZKoGUHugUzKKPCjDw
#else
#end
#end
#end

 

But in any case, Velocity is outputting exactly what you tell it to. Removing a "-" from a URL changes the URL, that's a significant character like any other (no such thing as a disposable character in a URL). 

 

I suspect you're trying to use Velocity to output a URL only, rather than an <a> (including the closing </a>). That's not supported, the whole <a> tag has to be generated in Velocity.


Either that or you're just dropping the link-like string into an email and expecting the email client to turn it into a clickable URL. That's always prone to major errors.

Maria_Riley1
Level 2

Re: How to cancel characters on a URL velocity token

Got it, 

removed extra $ and #end . 

Also encased the url on <a> </a> and it works. 

thanks so much!

SanfordWhiteman
Level 10 - Community Moderator

Re: How to cancel characters on a URL velocity token

OK, pls mark my answer as correct, thx.