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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 03:10 AM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 03:24 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 03:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2018 03:28 AM
yea, i was gonna add the same work of caution.
But thanks anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2022 04:15 AM
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.