Get ONLY last updated additional comments / worknotes in the Incident History

New Developer_S
Giga Sage

Hi,

Can somebody share the code for how to get

 

Get ONLY last updated additional comments / worknotes in the Incident History?

 

If you could give code, your response is much appreciated.

 

TIA .

2 REPLIES 2

Muhammad Khan
Mega Sage
Mega Sage

Try with below script in background script.

var gr = new GlideRecord('incident');
gr.get('<sys_id_of_incident_containing_comments_and_worknotes>');

gs.print('Last/Latest Comment: ' + gr.comments.getJournalEntry(1) + ' Last/Latest WorkNote: ' + gr.work_notes.getJournalEntry(1));
gs.print('All Comments: ' + gr.comments.getJournalEntry(-1) + ' All WorkNotes : ' + gr.work_notes.getJournalEntry(-1));

Hi @Muhammad Khan 

 

I want to write a business rule to apply for all . Can you please share the code ?