- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 09:23 AM
I need help with a script please. The design is that an approval is sent to a group by the workflow below. One of these approval users goes to the Service Portal, opens their requested approval, adds a comment, and then clicks the Approve button. Then the workflow creates the Catalog Task per the next workflow box. The script below is within the Catalog Task. I've tried several versions of this script, but nothing will copy the RITM comment to the CTASK.
User adds comment to requested approval and then clicks the Approve button
The script below copies a comment made in an actual approval to the task, but this is not what I need. The goal is to have a script that will grab the comment on the Requested Item and add it to the work notes on the Catalog Task that the workflow creates.
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=',''); // add this to only find approvals that have comments on them
apv.query();
while (apv.next()) { // change if to while so it will go through all approvals with comments
task.work_notes = "Approval Comments from " + apv.approver.name + ":\n" + apv.comments; // add approver name here
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 10:09 AM
if i read it again, seems like you just want update the RITM comments to catalog task .
if then can you try now.
gs.log('comments is '+ current.comments.getJournalEntry(1));
task.work_notes = current.comments.getJournalEntry(1);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 09:29 AM
added logs. please let me know the log result. approval is generating on request or ritm ?
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=',''); // add this to only find approvals that have comments on them
apv.query();
gs.log('row Count is '+ apv.getRowCount());
while (apv.next()) { // change if to while so it will go through all approvals with comments
task.work_notes = "Approval Comments from " + apv.approver.name + ":\n" + apv.comments; // add approver name here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 10:02 AM
Harshvardhan,
The approval is getting generated on the RITM. Please keep in mind though that the approver's comment is on the RITM and not the actual approval. In the service portal screenshot that I included, the comment is in the Activity Stream for Requested Item.
Thank you,
Shane

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 10:04 AM
can you confirm the log details ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 10:09 AM
if i read it again, seems like you just want update the RITM comments to catalog task .
if then can you try now.
gs.log('comments is '+ current.comments.getJournalEntry(1));
task.work_notes = current.comments.getJournalEntry(1);