Encrypting/Masking Variables in a Catalog Form (Integer field and String Field)

shahid1
Kilo Expert

Hi All,

We have a requirement here to make two of the catalog fields, in a form, encrypted/masked. (Basically the client wants us to make the fields look like a password field where and when user types in the text or integer it comes up in "*****" format or hidden format).

So , how to do that for a variable type string (Text Box) or Integer field? Anybody can help here?

Will that appear in the same way in the RITM form and TASK form?

And what will be the process to decry-pt or unmask it?

Thanks in Advance,

Shahid

23 REPLIES 23

Hello Rahul,



I ´m also trying to map a masked value form a catalog variable to a sncrypted type field on the sc_req_item form



Where should I add the script you suggested under a business rule?



var Encrypter = new GlideEncrypter();  


var variable_value1 = Encrypter.decrypt(current.variables.variable_name1);


var variable_value2 = Encrypter.decrypt(current.variables.variable_name2);   \



variable_value1 should be my catalog variable name in both cases?



--


Thanks


Miguel


Gurpreet07
Mega Sage

If you do not want to encrypt field value but only want to display it like a password then create a UI Macro having HTML code of input type password and then refer that macro in a variable of type Macro with label .


HTML Code for macro


<input type="password" name="pwdField" id="pwdField" />


Hi Gurpreet,



Thanks for the reply, i have already provided the client with this solution, but they want to have this field to be masked and look encrypted in the RITM or TASK form too.



And then we have a requirement to decry-pt it for further use.



If you could help me make the field encrypted at all levels then it would be great!.



RGDS,


Shahid


I think you will be able to do that as well, create an after Business rule on insert. user below method


Create an encryption context


To encrypt the value


COI - sys_id of the Encryption Context


current.fieldname.setContextID(COI); // Set the encryption context on the target field



below to show the value


current.fieldname.setDisplayValue(producer.fieldname.getDisplayValue()); // Set the plaintext as the display value, triggering the encryption process for the underlying database value




User should access to the encryption context, for more details refer below


Encryption Support - ServiceNow Wiki


rahulpandey
Kilo Sage

As rightly Gurpreet mentioned, You need to create a variable with type "Macro with Label" then create a UI macro with below code


<input type="password" name="somename" id="someid" />


Now In variable type specification tab select the macro. This may help you.