Display Only the Last 4 Digits of a Social Security Number

Your rating: None Average: 4 (2 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 42 weeks 3 days 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

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
The question below is to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.