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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2020 06:46 AM
I want to print worknotes of a particular record using background script.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2020 07:03 AM
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