Issue with Sequential Work Notes Updating in RITM Records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 02:02 AM
Hi Everyone, Need small help:
Hello everyone,
I am encountering an issue in ServiceNow regarding the work notes for RITM (Request Item) records. When I run my script to cancel requests, I observe the following behavior:
- Initially, the work notes are recorded separately, which is expected.
- After the state change activity, an additional work note is added that contains the concatenated messages.
Here is the script I am using:
var ritmArray = [ "RITM0174132", "RITM0174127" ]; var count =0; for(var i=0; i<ritmArray.length ; i++){ var ritm = new GlideRecord('sc_req_item'); ritm.addQuery('number',ritmArray[i]); ritm.query(); if(ritm.next()){ count++; ritm.stage = 'Request Cancelled' ; ritm.state = '4'; ritm.work_notes = 'In an effort to maintain data quality within ServiceNow, any requests older than 2 months are cancelled. Your request has met this criteria. Please resubmit the request if still needed. Thank you.'; ritm.work_notes = 'Cancelling the ritm on request of INC1882708'; ritm.update(); } } gs.print(count);
I would like to understand why the initial separate work notes are recorded first, followed by a concatenated entry after the state change. Is there a way to streamline this process to avoid redundancy in the work notes?
Any insights or recommendations would be greatly appreciated!
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 08:21 AM
Where is this code running? In a scheduled job? I'm honestly surprised you get anything other than 'Cancelling the ritm on request of INC1882708' in your work notes, based on this code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 08:34 AM
I ran your code and got the same results. Very strange. When I consolidated your work_notes into one line, it seemed to work. My code:
var ritmArray = [
"RITM0010014"
];
var count = 0;
for (var i = 0; i < ritmArray.length; i++) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', ritmArray[i]);
ritm.query();
if (ritm.next()) {
count++;
ritm.stage = 'Request Cancelled';
ritm.state = '4';
ritm.work_notes = 'In an effort to maintain data quality within ServiceNow, any requests older than 2 months are cancelled. Your request has met this criteria. Please resubmit the request if still needed. Thank you.\n\nCancelling the ritm on request of INC1882708';
ritm.update();
}
}
gs.print(count);