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

Harsh Vardhan
Giga Patron

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

}

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

can you confirm the log details ? 

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