Update RITM "Comments" and Work note fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 10:49 AM
I am trying to update both "Comments" and "Work Note" my Requested Item when approver reject, I used the following script in Run Script of my workflow:
var note ="This Retirement RITM is being rejected as the related change request was not approved" ;
var item = new GlideRecord('sc_req_item');
item.get(current.sys_id);
item.comments =note;
item.work_notes = note;
item.update();
However, both fields are not updated. Event I did run the following script in Back-ground script, but it still not works.
var note ="This Retirement RITM is being rejected as the related change request was not approved" ;
var item = new GlideRecord('sc_req_item');
item.get('896ae660dbe5c7007e94ff621f961985');
//gs.print(item.comments);
item.comments =note;
item.work_notes = note;
item.update();
gs.print(item.comments);
gs.print(item.work_notes);
Can anyone help?
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2018 02:38 AM
To update the REQ comments with the approval comments, you can write a onbefore BR on the sysapproval_approver table with a Filter Condition "State changes to Rejected"
and a script:
(function executeRule(current, previous /*null when async*/) {
// Copy the comments content to task table
var rec = new GlideRecord('task');
rec.addQuery('sys_id',current.document_id);
rec.query();
if (rec.next()) {
rec.comments.setJournalEntry(current.document_id.getDisplayValue()+" rejected with the following reason: " + current.comments);
rec.update();
}
})(current, previous);
Principal Platform Architect, Customer Success, ServiceNow