- 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 11:28 AM
Harshvardhan,
This is exactly what I needed and so simple! Thank you very much.
Shane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 11:01 AM
Why do the comments need to specifically be from the RITM if it's the same as what they've entered on the approval? If the comments are the same you can use the below or what you already have. Are the comments not the same?
To get comments from the RITM you'd use current.comments if the workflow is on sc_req_item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 11:30 AM
leahdany,
The comments aren't on the actual approval, but rather the Activity Stream of the RITM. That's the way the Service Portal is designed. I marked the answer from
Thank you,
Shane