Mask a part of a field for security reasons

Alexander Karam
Mega Contributor

Hi everyone, 

I am just starting out to learn about the platform and I need a bit of help. 

Can anyone tell me how to mask a part of a field for certain users. 

Example: 

If an User inputs his card number (1111-2222-3333-4444), I want to make it so that a non-admin user sees the field masked in the following way (****-****-****-4444). 

Can anyone help me in regards to what is the best way to do this. 

Thank you !  

1 ACCEPTED SOLUTION

oh, i see

what is the requirement for masking? do you need to mask while user typing it? (high risk, user might mistype the numbers) or after submit?

if the latter, i would do following:

1) add client script onchange for the field to format user's input in the format you need, so if user typing 1234555511112222, you script formats it 1234-5555-1111-2222

2) create business rule on insert/update and just have the masked field update as below

 

var maskedPrefix="****-****-****-";

current.yourfieldmasked = maskedPrefix + current.userinputfield.toString().slice(-4);

what do you think?

View solution in original post

6 REPLIES 6

nataliya_b
Tera Guru

I would have two fields for this: one for admin with clear user's input and second with partially masked data. Check if user has an admin role - show both- actual and masked, for non admin - show masked data field. The ACLs for these fields could be used for read access for admin/nonadmin

Greetings Nataliya, 

Thank you for the reasponce, that is a great idea regarding the visibility and using 2 fields. 

My main issue however is how to actually mask a field in service now. Is there any build in functuonality I can use or does it have to be scripted. 

Thank you in advance! 

Have a wonderful day!  

oh, i see

what is the requirement for masking? do you need to mask while user typing it? (high risk, user might mistype the numbers) or after submit?

if the latter, i would do following:

1) add client script onchange for the field to format user's input in the format you need, so if user typing 1234555511112222, you script formats it 1234-5555-1111-2222

2) create business rule on insert/update and just have the masked field update as below

 

var maskedPrefix="****-****-****-";

current.yourfieldmasked = maskedPrefix + current.userinputfield.toString().slice(-4);

what do you think?

Hi Nataliya, 

To answer your question it is the latter and I believe the solution you provided here is exactly what I asked for / need. 

Thank you so much for your help !

Have a lovely day !