SOLVED

Modifying field values using velocity script?

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: Modifying field values using velocity script?

$lead.subPartner.replaceAll("^Marriott - ","").replaceAll("^","a ").replaceAll("(?i)^a ([aeiou])","an $1")
Guitarrista82
Level 6

Re: Modifying field values using velocity script?

Thank you Sanford!

 

I updated the code as shown below, but am seeing an error when trying to preview it in email.

 

#set( $valueWithoutMarriottPrefix = $lead.subPartner.replaceAll("^Marriott - ","").replaceAll("^","a ").replaceAll("(?i)^a ([aeiou])","an $1") )
${valueWithoutMarriottPrefix}

 

 

Guitarrista82_0-1625780485479.png

 

What am I doing wrong?

 

Thank you, 

LK

 

Jo_Pitts1
Level 10 - Community Advisor

Re: Modifying field values using velocity script?

@SanfordWhiteman and @Guitarrista82 ,

Ignoring for a moment the value in a robust discussion on the use of Velocity, I have silly thought.  Namely, why not fix this problem in the actual Marketo data?

 

Surely a smart campaign that had as its smart list the field with the junk value, and then a flow step doing a change data value to the correct value would suffice?

 

Cheers

Jo

 

 

Guitarrista82
Level 6

Re: Modifying field values using velocity script?

Thank you for offering your insight, @Jo_Pitts1. Definitely not a silly thought.

I was able to fix the initial issue with the data by running a smart campaign in Marketo, but I received a request to transform how the existing values for the custom field appear in emails.

Unfortunately, our CRM is rather archaic and the management of data therein is not an easy undertaking. A request to change data values would most likely take several months to complete. And any data that flows in from our CRM to Marketo would override any values that get updated.

 

Definitely food for thought for longer-term implementation, but at the moment, it wouldn't be feasible with our time constraints.

 

Thank you,

 

LK

SanfordWhiteman
Level 10 - Community Moderator

Re: Modifying field values using velocity script?

True, if all the possible values are known and it’s a short list.
Jo_Pitts1
Level 10 - Community Advisor

Re: Modifying field values using velocity script?

Quite.  The use case here seemed very specific, hence why I suggested it 🙂

Guitarrista82
Level 6

Re: Modifying field values using velocity script?

@SanfordWhiteman I tried private messaging you but am not sure if the message went through because there was no confirmation on my end. Can you please confirm if the message was received? 

 

Thank you,

 

LK

SanfordWhiteman
Level 10 - Community Moderator

Re: Modifying field values using velocity script?

I didn’t get a DM.
Guitarrista82
Level 6

Re: Modifying field values using velocity script?

Thanks...I just resent and it looks like it was sent successfully this time.