Run a Business Rule when press button 'Post' on Work Notes or Additional Comments

TiagoPinto
Tera Contributor

Hi, ServiceNow Community, 

I want to run a Business Rule Script when I press the 'Post' button on the work notes or additional comments.
It is possible somehow?

 

Business Rule conditions:

TiagoPinto_1-1674131455008.png

This When to Run conditions only works if I press save button or submit.

Best Regards,

Tiago Pinto 

 

1 ACCEPTED SOLUTION

Sebas Di Loreto
Kilo Sage
Kilo Sage

@TiagoPinto 

When you press POST, you are actually saving a new record on the sys_journal_field table.

Business rules run on the server side so that is the table you would have to use for what you are trying to do but be careful with this table since it will be rather large.

 

This is an example script to look for the first comment 

var notesGR = new GlideRecord("sys_journal_field");
notesGR.addQuery('name', 'incident');   //looking just for comments on the incident table
notesGR.addQuery('element_id', current.sys_id);
notesGR.addQuery('element', 'comments');
notesGR.orderBy('sys_created_on');   //first comment
notesGR.query();

 


If I helped you with your case, please click the Thumb Icon and mark as Correct.


View solution in original post

2 REPLIES 2

Sebas Di Loreto
Kilo Sage
Kilo Sage

@TiagoPinto 

When you press POST, you are actually saving a new record on the sys_journal_field table.

Business rules run on the server side so that is the table you would have to use for what you are trying to do but be careful with this table since it will be rather large.

 

This is an example script to look for the first comment 

var notesGR = new GlideRecord("sys_journal_field");
notesGR.addQuery('name', 'incident');   //looking just for comments on the incident table
notesGR.addQuery('element_id', current.sys_id);
notesGR.addQuery('element', 'comments');
notesGR.orderBy('sys_created_on');   //first comment
notesGR.query();

 


If I helped you with your case, please click the Thumb Icon and mark as Correct.


Thank you @Sebas Di Loreto 
It worked!