Data Masking for Incident fields

Mayur Patil2
Tera Expert

Hi All,

I am working on Data masking for fields in the incidents table. Here I am using a Client script to mask the data with Asterisk. 

So, there are errors that I am facing

1) For the Incident list view the masking is only applied after updating the incident record.

 

So can you help me resolve this situation?

 

Thank you

 

Client Script :-

// Client Script - Display masked data in incident table
function onLoad() {
    // Specify the target table and fields
    var targetTable = 'incident';
    var targetFields = ['short_description''description'];

    // Run the client script on the incident form and incident list
    if (g_form) {
        var tableName = g_form.getTableName();
        var isTargetTable = tableName === targetTable;
        var isTargetList = tableName === 'incident_list';

        if (isTargetTable || isTargetList) {
            // Iterate over the target fields
            for (var i = 0; i < targetFields.length; i++) {
                var targetField = targetFields[i];

                // Get the field element on the form/list
                var fieldElement = isTargetTable ? g_form.getControl(targetField) : gel('list_' + targetField);

                if (fieldElement) {
                    // Get the current value of the field
                    var fieldValue = isTargetTable ? g_form.getValue(targetField) : fieldElement.getAttribute('value');

                    // Create a masked value with asterisks
                    var maskedValue = '*****';

                    // Display the masked value in the field element
                    if (isTargetTable) {
                        fieldElement.value = maskedValue;
                    } else {
                        fieldElement.setAttribute('value', maskedValue);
                        fieldElement.innerHTML = maskedValue;
                    }

                    // Disable the field to prevent editing
                    if (isTargetTable) {
                        g_form.setReadOnly(targetField, true);
                    } else {
                        fieldElement.setAttribute('readonly''true');
                    }
                }
            }
        }
    }
}
3 REPLIES 3

Samaksh Wani
Giga Sage
Giga Sage

Hi Mayur,

 

Plz try your data masking Script with On Change Event.

 

Mark my Solution as Accept, if you find it helpful.

 

Regards,

Samaksh

Hi @Samaksh Wani 

Thank you for your solution. I tried it but it didn't work.

Hello Mayur,

 

If it is Custom Field, you can change its type to password 1 way encrypted.

 

Mark my Solution as Accept, if you find it helpful.

 

Regards,

Samaksh