Hi,
I am looking to send out a communication via Text and Email to our customers that includes that persons policy number. Unfortunately our legal department will not let us send the entire policy number digitally. We are permitted to send the last 4 digits however. Is there a way with Velocity Scripting where I'd be able to null out the first 7 or 8 digits of this persons number?
Example - A persons policy number is 077063253. With Velocity Scripting can I get it to show as XXXXX3253, or is there another way where I can change the data value to a new field to only include the last 4 digits where 077063253 is changed to 3253 on a different field?
Solved! Go to Solution.
${lead.PolicyNumber.replaceAll(".(?=.{4,}$)","X")}
Thank You very much Sanford, this worked!
Great, I also edited to be less verbose just now.
Hi Sanford,
Just wanted to follow up on this. It works great in email but I tried to implement it into a text message using a webhook and I got a Code Block. Is this token able to be utilized in text message? Error is below. Note that I replace the X with * and the field is "lead.policy", not PolicyNumber"
{"codeBlock":"${lead.policy.replaceAll(\".(?=.{4,}$)\",\"*\")}","scriptingObjects":{"standard":{"2":{"label":"Person","fields":{"2368":{"label":"Policy"}}}}}}.
Velocity doesn't get parsed in webhooks.
You could do 2 things:
If you removed the X from the code so that it read:
${lead.PolicyNumber.replaceAll(".(?=.{4,}$)","")}
Would that render the last four and not add the X's? or is there a better way of doing that?
Yes, that would remove all but the last 4. It's not the most obvious way to do it, but maintains symmetry with the original code and w/strings as short as a CC# you'd never notice a difference.
(Once you don't need the X's a substring + max length calculation is, again speaking theoretically, faster.)