Business Rule - Add automatic comments as admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 02:05 AM
Hi All,
Want to add automatic comments in an incident additional comments field when new incident is inserted.
My issue is, added comments are updated by the current user, But I want it as Admin. Since it is an automatic comments.
How to do that ?
If anyone know the solution kindly, help me.
Business Rule:
Before insert,
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.comments = "Thank you for contacting TEST";
})(current, previous);
The comments here added by the current user, I want it as System Administrator
Thanks & Regards,
Anna Silva

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 02:12 AM
Hello Siva ,
Use the below sample code and try.
var gr = new GlideRecord('sys_user');
gr.get('user_name', "System Administrator");
var ou = gs.getSession().impersonate(gr.sys_id);
current.comments = "Thank you for contacting TEST";
current.update();
gs.getSession().impersonate(ou);
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 02:46 AM
Thanks for your response
I tried this & it's working but getting the given error,
But incident has been created successfully.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 02:49 AM
Please use setJournalEntry() to avoid these errors.
Make sure you do not include current.update() in a before insert business rule.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 03:04 AM
hi Anna Silva,
Paul's solution is way to go; if that too didn't work then try my solution of inserting a record directly on to sys_journal_field table.