cancel
Showing results for 
Search instead for 
Did you mean: 

SSN Normalization

Spedding
Enthusiast

Hi,

Has anyone written an SSN normalization function?

Thanks,

Joe

12 REPLIES 12

AnthonyValidity
Validity Team Member
Validity Team Member

Hi @Spedding,

Happy to help where I can.  Do you mean to change this xxxxxxxxx to xxx-xx-xxxx?  If so, I wrote this for you:

 

 

CONCATENATE(Left( ${Phone} , 3),"-",Mid_2( ${Phone}, 3,2),"-",Right( ${Phone} , 4))

 

 

I was using the phone field to easily test the formula - just replace it with your field.

Let me know if this helps.

 

Anthony Lardiere Jr
Senior Customer Success Manager

AnthonyValidity
Validity Team Member
Validity Team Member

Also, if you're just looking to identify malformed SSN, you can use this formula:

RegExMatch(${Phone}, "^[0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]$")

 

Anthony Lardiere Jr
Senior Customer Success Manager

Spedding
Enthusiast

Thank you!!!!  I will try it today.  Looks great!

AnthonyValidity
Validity Team Member
Validity Team Member

You're welcome!  It's my pleasure 🙂

If this ends up working for you, please mark it as a solution so that other customers can easily find it.  Keep me posted!

Anthony Lardiere Jr
Senior Customer Success Manager

Spedding
Enthusiast

Hi Anthony.  The replacement value is being treated as a literal.  Am I missing something?  Below is a screenshot of the specification.

 

Spedding_0-1680272730834.png

 

Hi @Spedding,

You're using the "Specified Value" action.  You need to click the "Formula" action to enter the formula.

AnthonyValidity_0-1680273319439.png

Anthony Lardiere Jr
Senior Customer Success Manager

Spedding
Enthusiast

Oh my, LOL, I know that and have no idea what I was thinking.  Anyway, I corrected it and it's returning all blank values.

Spedding_2-1680274122653.png

<REDACTED SCREENSHOT>

 

 

lol No worries, it happens to the best of us!  So for RegExMatch it only identifies the malformed values, but does not fix them.  You'll want to use the original formula I provided to fix those that have no dashes.

 

CONCATENATE(Left( ${Phone} , 3),"-",Mid_2( ${Phone}, 3,2),"-",Right( ${Phone} , 4))

 

Of course, replace the phone field with your custom field.

Anthony Lardiere Jr
Senior Customer Success Manager

Spedding
Enthusiast

Hi Anthony,

Sorry for just getting back to you.  I had a family emergency as was out of the office for a bit. Anyway, the following error is being given.  Have you seen it before?

[2023-04-06 09:14:29.047] [error] [console] DTV Error! Something unexpected happened.
'RegExMatch(${TargetX_SRMb__SSN__c}') AND (TargetX_SRMb__SSN__c != '"^[0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]$")'))
^
ERROR at Row:1:Column:127
Invalid string literal '"^[0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]$")'. Illegal character sequence '\-' in string literal.
http://localhost:8080/5.24.1/js/main.js:2