Copy comments and work notes from REQ to RITM

jtorres
Kilo Contributor

Hi Team,

I have an implementation in which we disabled the shopping cart from the service catalog, therefore, for each REQ we have only one RITM, we now have a requirement to copy all the comments and work notes from the request to its related RITM and the related Catalog tasks, in order to improve the interaction between end users who interact in the REQ and fulfiller users who interact in the RITM. Has any of you guys worked in something like this?

Any help would be greatly appreciated.

Thank you.

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


i assume that you want to copy the comments from REQ to RITM and then RITM to SCTASK as soon as comments are inserted on REQ.

 

IF so then use after update BR on REQ and condition will be comments change

See below:

Condition : current.comments.changes() || current.work_notes.changes()

Script:

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

// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request',current.sys_id);
gr.query();
while(gr.next()){
gr.comments = current.comments;
gr.work_notes = current.work_notes;
gr.update();

var tsk = new GlideRecord('sc_task');
tsk.addQuery('request_item',gr.sys_id);
tsk.query();
while(tsk.next()){
tsk.comments = current.comments;
tsk.work_notes = current.work_notes;
tsk.update();
}
}
})(current, previous);

 

Thanks,
Ashutosh Munot

View solution in original post

23 REPLIES 23

Thanks for all your help!

Regards!

Hi Ashutosh,

I am trying to copy work notes from Catalog task to change task. I wrote code according to my requirements based on the above code, but the problem is  work notes in copying twice on the change task.

Could you suggest anything?

 

Thanks,

Vinay

HI,

This can be because the BR is getting triggered twice. check that one.

Thanks,
Ashutosh

Thanks for the reply!

I have a requirement to copy work notes from Catalog task to change task. Here the parent of the change request is RITM. I am new to scripting and unable write logic for this.

Could you please help me with the code. Please see the attachment.