How can we anonymize "sys_updated_by" and "sys_created_by" user fields?

xinyao
ServiceNow Employee
ServiceNow Employee

Once we define a survey as "Anonymize response", we want to hide survey user' name on whatever records related to their response, such as "survey instance" table. However, survey user's name is still shown in the fields of "sys_updated_by" and "sys_created_by" on the response records. These two user fields are controlled by platform mechanism and they will be updated automatically by current logged in user.

The solution we have been trying is to use "impersonate" functionality. We tried to impersonate as 'Guest' user when taking anonymize survey. However, it's not going to work either because "impersonate" is not allowed for all login users. For example, 'Abel Tuter' cannot impersonate as 'Guest' user.

Do we have any anonymous mode to solve this issue? Thanks in advance!

 

1 ACCEPTED SOLUTION

Vikram Reddy
Giga Guru

Hi xinyao,

Use this script for after business rule on 'asmt_assessment_instance_question'

set conditions on when to run

var a = current.instance.sys_updated_by;
var b = current.instance.sys_created_by;

if(a || b){
var gr = new GlideRecord('asmt_assessment_instance');
gr.get(current.instance);
gr.autoSysFields(false);
gr.sys_updated_by = '';
gr.sys_created_by= '';
gr.update();

}
current.autoSysFields(false);
current.sys_updated_by = '';
current.sys_created_by= '';

current.update();

 

Thank you,

Vikram

 

View solution in original post

13 REPLIES 13

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

There exists an option of autoSysFields that can be used whenever Survey record is inserted. Haven't tested but can be one of possible options.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

xinyao
ServiceNow Employee
ServiceNow Employee

Thank you for the suggestion! By reading from document, "autoSysFields(false)" will ignore all of these fields, such as "sys_updated_by", "sys_updated_on", "sys_mod_count", "sys_created_by", and "sys_created_on". However, we still want to keep updating "sys_updated_on" and "sys_created_on". Can we specify which fields to be updated?

Hi xinyao,

 

we can't specify, it will disable updating all system fields

 

Thanks,

Vikram

xinyao
ServiceNow Employee
ServiceNow Employee

Thank you Vikram. Do you know any other approach?