Trim http:// or https:// from field value. Via Velocity or other way...? | Community
Skip to main content
New Participant
May 10, 2021
Solved

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

  • May 10, 2021
  • 1 reply
  • 1627 views

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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>

 

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
May 10, 2021

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>

 

 

New Participant
May 11, 2021

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