- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Script/Business Rule to copy Attachments from Child 'Security Incident' to Parent 'Security Incident'
Dear ServiceNow Community Colleagues, I would greatly appreciate your help/guidance on how to achieve the following.
I need to configure for my client, so that when a Child Security Incident is related/linked to a Parent Security Incident, that attachments that are on the child security incident record are copied across as attachments on the Parent Security Incident record.
Please could you let me know the Business Rule / Script that I need to achieve this, also minimising any performance issues when doing this. Does it need to be an Insert, Update or Async Business Rule?
It is all related to 'Security Incident Response', so the table is 'sn_si_incident'.
Both the child ticket and parent ticket would be Security Incident, on the same table: sn_si_incident
Thanks very much for your help.
Kind Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @WazzaJC ,
(function executeRule(current, previous /*null when async*/) {
// Check if the record has a parent
if (!current.parent_incident) {
return;
}
// Get the parent Security Incident record
var parent = new GlideRecord('sn_si_incident');
if (!parent.get(current.parent_incident)) {
return;
}
// Copy attachments from the child to the parent
var attachments = new GlideRecord('sys_attachment');
attachments.addQuery('table_name', 'sn_si_incident');
attachments.addQuery('table_sys_id', current.sys_id);
attachments.query();
while (attachments.next()) {
GlideSysAttachment.copy('sn_si_incident', current.sys_id, 'sn_si_incident', parent.sys_id);
}
})(current, previous);
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
the business rule is meant to work when you add file on Child, it will copy to parent
What's your business requirement?
1) when child incident is created from parent then file from Parent should be copied -> for this I already shared logic above
OR
2) when file is attached to child, add that same to parent -> for this I already shared logic above
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
the business rule is meant to work when you add file on Child, it will copy to parent
What's your business requirement?
1) when child incident is created from parent then file from Parent should be copied -> for this I already shared logic above
OR
2) when file is attached to child, add that same to parent -> for this I already shared logic above
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Yes the requirements/use cases are correct @Ankur Bawiskar , but I have configured exactly as above, but this script and conditions do not work for me. I'm wondering if you have configured and tested your side and you can see them working. I have literally configured exactly as your guidance but the business rule doesn't seem to trigger, maybe if you can double check your side and let me know, many thanks once again Ankur. I have attached screenshots to show my configuration, as per your guidance. But when I attach a child security incident to a parent security incident and save, the attachments do not copy across to the parent record, from the child record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
what debugging did you do?
did you add gs.info() and see BR triggered or not?
what are your findings?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @WazzaJC
You can watch my video !!
https://www.youtube.com/watch?v=4P-AUaNQ8EE&list=PLKH9bPqlw1neHQZWQpYXHKy7LGiG9lhZn
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/