Approval Record comments to copy to Parent RITM

Tfnhodgi
Tera Contributor

I know there are multiple threads on this but I have had no luck. For example add Website to whitelist. This RITM will go to 4 Security people where only one needs to approve. If they reject or simply add a comment we want that comment to copy to the Parent RITM. I have looked at many threads and all are not working for me. 

Business rule 

Table - Approval [sysapproval_approver]

When to run- Before / on Update /  filter - I have it set to Comments changes. 

My current Script-  Not sure how close this is to working

(function executeRule(current, previous /*null when async*/) {
 
    var grRITM = new GlideRecord('sc_req_item');
    if(grRITM.get(current.sysapproval)) {
    grRITM.comments = "Comment copied from approval record:\n\n" + current.comments;
    grRITM.update();
}
})(current, previous);

 

 

1 ACCEPTED SOLUTION

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Tfnhodgi 

 

you can write before business rule  and use the below Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    // Get the parent RITM (Request Item)
    var reqitem = new GlideRecord('sc_req_item');
    reqitem.addQuery('sys_id', current.document_id);
    reqitem.query();
    if (reqitem.next()) {
        reqitem.comments = reqitem.comments + "\n" + current.comments.getJournalEntry(-1); 
        reqitem.update(); 
    }

})(current, previous);

 

It is working in my pdi

Thanks and Regards

Sai Venkatesh

View solution in original post

9 REPLIES 9

Hi @Tfnhodgi 

 

I have tried the code and it is working my PDI

 

Thanks and Regards

Sai Venkatesh

Strange... Here is what I have setup on myside. Only other thing is we have a Work Note that populates when this ticket is created. Can that break this code by any chance? I am confused why this isn't working for me. I appreciate your help.

sn_pict.png

Hi @Tfnhodgi 

In my PDI the same code is working and based on your information provided I think the work notes code is affecting may be.

 

 

Thanks and Regards

Sai Venkatesh

Hi @SAI VENKATESH thank you for troubleshooting this with me. I created a new CI without the worknotes and the code worked as it should. Weird how adding notes through the flow would stop this but we figured it out. Thanks!

Tfnhodgi
Tera Contributor

Just wanted to update. It is not the worknotes. Not sure what it is causing it not to work on the old CI, but it has to be on the Catalog item side from my testing. I will update when I figure out what is causing the old one not to work.