- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 02:06 PM
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!
Solved! Go to Solution.
- Labels:
-
Multiple Versions
-
Survey Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 04:12 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 06:09 PM
Thank you so much for the help! One question, is this for "after update" business rule? Will "current.update()" cause an infinite loop for updating it? If this is for "after insert" business rule, then what will happen when we update instance question?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 06:33 PM
Yes this is after insert.
"current.update()" will cause an infinite loop for updating when used in before but not in 'after' business rules. Because in before business rules system however executes current.insert() or current.update() and if you again specify it creates an infinite loop triggering the business rule until it exhausts
If you update the record the business rules wouldnt trigger and need not worry about it as at the time of insertion we are clearing out those 2 fields. If you don't want to see sys_updated_by after updating, include after update in the business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 06:44 PM
So appreciate! Nice explanation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 06:57 PM
Glad it helped, Please connect with me on Linkedin
www.linkedin.com/in/vikram-reddy-b48047144
Just trying to grow my network in ServiceNow space
Thank you,
Vikram