SOLVED

Re: Hide Numbers in velocity Scripting

Go to solution
James_Walsh
Level 3

Hide Numbers in velocity Scripting

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Hide Numbers in velocity Scripting

${lead.PolicyNumber.replaceAll(".(?=.{4,}$)","X")}

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Hide Numbers in velocity Scripting

${lead.PolicyNumber.replaceAll(".(?=.{4,}$)","X")}
James_Walsh
Level 3

Re: Hide Numbers in velocity Scripting

Thank You very much Sanford, this worked!

SanfordWhiteman
Level 10 - Community Moderator

Re: Hide Numbers in velocity Scripting

Great, I also edited to be less verbose just now.

James_Walsh
Level 3

Re: Hide Numbers in velocity Scripting

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"}}}}}}.

SanfordWhiteman
Level 10 - Community Moderator

Re: Hide Numbers in velocity Scripting

Velocity doesn't get parsed in webhooks.

You could do 2 things:

  1. Use an SMTP-to-SMS gateway, i.e. send an alert (which would execute Velocity) to a service that can turn SMTP into texts
  2. Pass the data to an intermediate webhook which could do this same masking logic (in, say, JavaScript) and then forward the call to your SMS service
Travis_Schwartz
Level 4

Re: Hide Numbers in velocity Scripting

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?

SanfordWhiteman
Level 10 - Community Moderator

Re: Hide Numbers in velocity Scripting

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.)