Using a scheduled job to add an additional comment to a RITM

Erik Stuer
Tera Guru

I am trying to use a scheduled job to add an additional comment to RITM that meet a certain query. I want RITM that have the state open, approval requested, and created date more than 6 and less than 9 days from the query. Here is the code I came up with, but it isn't making any additional comments.

var gr = new GlideRecord('sc_req_item');
gr.addQuery('state', 'open');
gr.query();

while (gr.next()) {
var comment = 'New comment here?';
gr.work_notes = comment + '\n\n' + gr.work_notes.getJournalEntry(1);
gr.update();
}

1 ACCEPTED SOLUTION

Erik Stuer
Tera Guru

Had a lot of issues with the scheduled job. One being testing was hard since it had to query soooo many records it actually slowed down the whole instance for a whole afternoon of testing. Ended up making it work with a flow. Trigger was when a request was made we did a wait for duration and then looked up the ritm table for those created relative to before 5 days ago and after 7 days ago then updated the record with the additional comment. 

View solution in original post

10 REPLIES 10

Erik Stuer
Tera Guru

Had a lot of issues with the scheduled job. One being testing was hard since it had to query soooo many records it actually slowed down the whole instance for a whole afternoon of testing. Ended up making it work with a flow. Trigger was when a request was made we did a wait for duration and then looked up the ritm table for those created relative to before 5 days ago and after 7 days ago then updated the record with the additional comment.