The CreatorCon Call for Content is officially open! Get started here.

How to copy parent incident comments to child incident and child incident to parent

Rajababu
Giga Guru

I am facing issue it's only work one side only .

How to copy parent incident comments to child incident and child incident to parent 

6 REPLIES 6

Anurag Tripathi
Mega Patron
Mega Patron

Since you want to copy it both ways, you need to write a business rule and whenever cimment changes, you have to query on all child and parent of that incident and copy the comments in there.

 

var gr = new GlideRecord('incident');

var qc = gr.addQuery('parent.sys_id', current.sys_id); //all child incident
qc.addOrCondition('sys_id', current.parent.sys_id); //parent

gr.query()

while(gr.next())

{

gr.comments=current.comments;

gr.update();

}

-Anurag

Be careful with this. This could result in a endless chain of updation of parent updating child and vice versa.

Make sure that your business rule conditions to prevent race condition.

yea, i was gonna add the same work of caution. 

But thanks anyway.

-Anurag

I have tried this script but its only working on way i.e its only copying comments of parent incident to child , can you suggest what changes I can make to copy child incident comments on parent incident.