SOLVED

Re: Trim http:// or https:// from field value. Via Velocity or other way...?

Go to solution
hblifeguard2020
Level 1

Trim http:// or https:// from field value. Via Velocity or other way...?

Hi Community!

 

I am looking for a way to edit/trim a field value, removing the HTTP:// or HTTPS://   

 

Background: I am receiving a link from SFDC in a custom field on the contact object. I want to use this link as the main CTA in an email to the contacts, it is unique to each contact. But, as we all know when we use a token value as a link we must insert it without the HTTP//: or HTTPS:// and hard code the protocol into the email code, so Marketo will notice the protocol and properly wrap the link in tracking shortener.

 

How do I deal with this value having the http:// or https:// in it can I trim it with a velocity script? Is there an operational program I can rig up to trim the value? Unfortunately I cannot request that the value be modified at the source because other integrated systems and processes use the value as-is in SFDC.

 

Any wizard ideas out there?

 

Many thanks in advance.

 

Best,

Eric Rex

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Trim http:// or https:// from field value. Via Velocity or other way...?

Velocity can't make permanent changes to fields (so there could never be an operational trim-the-value campaign). It can do incredibly elegant/complex things with how fields display in an email, but the underlying value does not change.

 

But in this case, you shouldn't need a permanent change.

 

Simply have a Velocity script that outputs the entire anchor tag (including opening <a> and closing </a>) as that's how to properly output links from Velocity anyway:

 

#set( $fieldWithScheme = $lead.originalField)
#set( $fieldWithoutScheme = $fieldWithScheme.replaceAll("^https://","") )
<a href="https://${fieldWithoutScheme}">Click here</a>

 

 

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Trim http:// or https:// from field value. Via Velocity or other way...?

Velocity can't make permanent changes to fields (so there could never be an operational trim-the-value campaign). It can do incredibly elegant/complex things with how fields display in an email, but the underlying value does not change.

 

But in this case, you shouldn't need a permanent change.

 

Simply have a Velocity script that outputs the entire anchor tag (including opening <a> and closing </a>) as that's how to properly output links from Velocity anyway:

 

#set( $fieldWithScheme = $lead.originalField)
#set( $fieldWithoutScheme = $fieldWithScheme.replaceAll("^https://","") )
<a href="https://${fieldWithoutScheme}">Click here</a>

 

 

hblifeguard2020
Level 1

Re: Trim http:// or https:// from field value. Via Velocity or other way...?

Thank you so much Sir!

You are right I just need to solve for the link in the email and not affect the field's stored value.  I really appreciate your help, this time an the 100 other times I have used your solutions. lol