How To get Latest Comment On incident.

Rehan7
Kilo Contributor

i want get latest comment on incident form. when incident state is In Progress and additional comment Changes.

Using Business rule GlideRecord.

1. Create Business Rule - On before update

state - In Progress.

And 

Additional Comment Change

Script -:

var gr = new GlideRecord('sys_journal_field');
gr.addEncodedQuery('element=comments');
gr.addQuery('element_id', current.sys_id);
gr.addQuery('sys_created_by', '!=', current.caller_id);

gr.query();
if (gr.next()) {
current.setValue('description', gr.value);
}

 

 

7 REPLIES 7

@Rehan 

Thank you for marking my response as helpful.

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

DanielCordick
Mega Patron
Mega Patron

ive grabbed the latest comments or work_notes with with something like this

 

var notes = current.comments.getJournalEntry(1);
var Content = notes.split("(Comments)\n");
var lastComment = Content[1].toString();

New Developer_S
Giga Sage

Hi, 

 

On which table we have to apply this business rule ?