Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Masking variables in incident using business rule script

FaizDev101
Tera Expert

I have created a business rule to mask the variables in incident variable editor when submit a record producer.

 

(function executeRule(current, previous /*, gs*/) {

var variablesToMask = ['variable1', 'variable2', 'dob'];

for (var i = 0; i < variablesToMask.length; i++) {
var variableName = variablesToMask[i];
if (current.variables[variableName]) {
current.variables[variableName] = '********';
}
}
})(current, previous);

 

I am getting output like this,

FaizDev101_0-1695630663662.png

The date of birth variable type is "Date" I also need to mask that,

Some modification is needed in that script. Please guide me with that.

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@FaizDev101 

so it's not working for date variable?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

yes working only for variable which is string type

@Ankur Bawiskar 

hi, do we have any solution for this ?

Regards

faiz

@FaizDev101 

Haven't tried it but did you try to use DOM manipulation on client side?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader