I have an existing lead field that contains the value for user Company Names, and with some company name ending in "Inc." we get an extra period at the end of the sentence where the token is placed.
I want to set up a script token that can identify if the last character in the lead field string is a period and remove it. I've looked into substring a bit, but haven't found a working solution.
Does anyone have any suggestions?
Solved! Go to Solution.
#set( $stripTrailingDot = $YourField.replaceAll("\.$","") )
Of course.
#set( $stripTrailingDot = $YourField.replaceAll("\.$","") )
Thank you for getting back to me. When I placed the code into the token, it returns the varibale as text. In the image below, I was testing our original token next to my new token to see how it renders, and as you can see I'm getting "$stripTrailingDot" as text.
I'm fairly new at using velocity script and don't know exactly how to properly display the value of the lead. The code is defined below.
#set( $stripTrailingDot = $lead.Company.replaceAll("\.$","") )
${stripTrailingDot}
Should I be referencing something other than $stripTrailingDot to get my lead.Company value to display?
Do you have that field checked in the tree on the right-hand-side of Script Editor?
No, I do not, should I have that field checked?
Of course.