Business Rule to copy approval/approver comments to the Requested Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2013 06:27 AM
I found a script on the forum for the workflow after the approval and it seems to be working but we'd like to setup a Business Rule instead to update the RITM with the Approver Comments. We have some that reply to the email to approve and then minutes later reply back with comments. The workflow script doesn't capture the new comments if they've already approved. We want to update the RITM anytime comments are added to the approval.
This is the run script in the Workflow on the sc_req_item table.
var app = new GlideRecord('sysapproval_approver');
var qc1 = app.addQuery('sysapproval', current.sys_id);
var qc2 = app.addQuery('state', 'approved');
qc2.addOrCondition('state', 'rejected');
app.query();
while (app.next()) { // change if to while so it will go through all approvals with comments
current.u_approver_comments += "\nApprover Name: " + app.approver.name; // add approver name here
current.u_approver_comments += "\nApproval Status: " + app.state;
current.u_approver_comments += "\nApprover Comments: " + app.comments;
current.u_approver_comments += "\n----------------------------------------";
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2019 11:42 AM
This is the one I wrote for copying Approvers comments to Change Request. You can modify this for RITM.
Table - sysapproval_approver
When - after
Insert, Update
Filter - Comments Changes
Script -
(function executeRule(current, previous /*null when async*/) {
var gr= new GlideRecord('change_request');
gr.get(current.getValue('sysapproval'));
gr.work_notes=current.comments.getJournalEntry(1);
gr.update();
})(current, previous);
Let me know if it helps.
Thanks,
Akshya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2019 12:05 PM
Try this
Tyr this.
(function executeRule(current, previous /*null when async*/) {
var user = current.approver.name;
var sr = new GlideRecord('sc_req_item');
sr.get(current.sysapproval);
sr.comments = "Comment copied from approval record:\n" + "Approver :-" +user+ " " +current.state+" " +"your request and added following comment :\n\n" +current.comments.getJournalEntry(1); // change the comment as you desire
sr.update();
})(current, previous);