How to get and print worknotes for a particular RITM record using background script in ServiceNow by passing sysid of the same ?

ITSM ServiceNow
Kilo Explorer

I want to print worknotes of a particular record using background script.

1 REPLY 1

Sudhanshu Talw1
Tera Guru

Hi,

//Calling function

getWorkNotes();

//Function to get WorkNotes

function getWorkNotes(){

var allWorkNotes=[];

var sysId="--SYSID--";

var gr=new GlideRecord("sc_req_item");

gr.addQuery("sys_id",sysId);

gr.query();

if(gr.next()){

var worknotes_str=gr.comments.getJournalEntry(-1);

var work_notes = work_notesStr.split("\n\n");

for (var x = 0; x < work_notes.length; x++) {
var current_work_note = {};
if (work_notes[x] != '') {
current_work_note.type = 'work_note';
current_work_note.text = work_notes[x];
work_note_date = work_notes[x].split(' ');
current_work_note.date = work_note_date[0] + ' ' + work_note_date[1];
allWorkNotes(current_work_note);
}
}

}

}

Thanks

Sudhanshu