Display Only the Last 4 Digits of a Social Security Number

Your rating: None Average: 4 (6 votes)

The PeopleCode below will only display the last 4 digits of a social security number. I have placed the code in a Component PostBuild event and it works perfect.

DERIVED_HR.SOCIAL_SECURITY_NUMBER = Replace(DERIVED_HR.SOCIAL_SECURITY_NUMBER, 1, 7, “XXX-XX-);

Here, I’m using the replace PeopleCode built-in function. The functions takes the value from a the above field, starts at position 1 and replaces the 1st 7 characters with the string “xxx-xx-”.
The result:
After this code gets executed, SSN on a page should show up as xxx-xx-5623

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
Sri's picture
Sri (not verified)
Display Only the Last 4 Digits of a Social Security Number

Hi there,

Can you elaborate this peoplecode with the example. I did not under stand this peoplecode.

CompShack's picture
User offline. Last seen 4 years 39 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Code should be easy

Lets say you have a field on a page (SOCIAL_SECURITY_NUMBER) that displays a social security number. The field is on record DERIVED_HR.
The above code looks at DERIVED_HR.SOCIAL_SECURITY_NUMBER (your field on the page), and then replaces the 1st 7 character with “XXX-XX-” (Replace(DERIVED_HR.SOCIAL_SECURITY_NUMBER, 1, 7, “XXX-XX-”)

n/a
Guest's picture
Guest (not verified)
Re: Display Only the Last 4 Digits of a Social Security Number

Can you show the whole function please?

Thanks

Guest's picture
Guest
Re: Display Only the Last 4 Digits of a Social Security Number

SUBSTR(A.EMPLID,6,4)

A.EMPLID = The SSN
6 = Starting character
4 = Qty Characters to display