Catalog Task workflow activity script to copy RITM comment to task work notes

shane_davis
Tera Expert

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.  

 find_real_file.png

User adds comment to requested approval and then clicks the Approve button

 find_real_file.png

 

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

}

1 ACCEPTED SOLUTION

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);

View solution in original post

7 REPLIES 7

Harshvardhan,

 

      This is exactly what I needed and so simple!  Thank you very much.  

 

Shane

leahdany
Giga Guru

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.

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 @harshvardhan correct.

 

Thank you,

Shane