The CreatorCon Call for Content is officially open! Get started here.

Business Rule - Add automatic comments as admin

SNOW User8
Giga Guru

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

find_real_file.png

Thanks & Regards,

Anna Silva

24 REPLIES 24

sushant007
Kilo Guru

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();


Hi Sushant Malsure




Have tried this one, but it's not working


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();


The SN Nerd
Giga Sage
Giga Sage

Before Business Rule on Incident



(function executeRule(current, previous /*null when async*/) {


current.comments.setJournalEntry('Thank you for contacting TEST', 'admin');


})(current, previous);



https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GlideElement-setJournalEntry_Object...



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

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.