03-28-2023 11:37 AM
Hi,
Has anyone written an SSN normalization function?
Thanks,
Joe
03-30-2023 12:35 PM - edited 03-30-2023 12:39 PM
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.
03-30-2023 12:51 PM
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]$")
03-31-2023 05:51 AM
Thank you!!!! I will try it today. Looks great!
03-31-2023 06:37 AM
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!
03-31-2023 07:26 AM
Hi Anthony. The replacement value is being treated as a literal. Am I missing something? Below is a screenshot of the specification.
03-31-2023 07:35 AM
Hi @Spedding,
You're using the "Specified Value" action. You need to click the "Formula" action to enter the formula.
03-31-2023 07:48 AM - last edited on 03-31-2023 07:57 AM by AnthonyValidity
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.
<REDACTED SCREENSHOT>
03-31-2023 07:51 AM - edited 03-31-2023 11:01 AM
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.
04-06-2023 06:16 AM
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
Get industry news, expert insights, strategies, and hot tips, served up fresh every week.
Visit the Validity blog