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:18 AM
change the business rule to After business rule and add following code:
var gr = new GlideRecord('sys_journal_field');
gr.name='incident';
gr.element_id = current.sys_id;
gr.element='comments';
gr.sys_created_by= 'System Administrator';
gr.value='Thank you for contacting TEST'; // your message here
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 04:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2017 01:56 AM
You mind trying this way?
change the business rule to After insert business rule and add following code:
var gr = new GlideRecord('sys_journal_field');
gr.name='incident';
gr.element_id = current.sys_id;
gr.element='comments';
gr.sys_created_by= 'System Administrator';
gr.value='Thank you for contacting TEST'; // your message here
gr.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 02:20 AM
Before Business Rule on Incident
(function executeRule(current, previous /*null when async*/) {
current.comments.setJournalEntry('Thank you for contacting TEST', 'admin');
})(current, previous);
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:35 AM
Hi Paul Morris
Thanks for your time.
I have tried this one but it's not working on Before insert condition, it's working in after insert condition.