Copy attachment from old HR case and transfer it to new HR case and delete attachment from old case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 11:42 PM
Hello Community,
have a requirement to copy an attachment from an old HR case and transfer it to a new HR case. Additionally, I would like to delete the attachment from the old case.
Could you please assist me with this process?
Thank you in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2025 12:05 AM
when the new HR case is created, if it stores reference somewhere of old HR case then you can do this
1) use after insert BR on HR Case table
2) copy the attachment from old to new
3) then delete the attachments from old HR case
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
07-31-2025 12:12 AM
I believe transferred_from is a field on HR case and it will store the OLD HR Case reference when the new HR case is created.
You can use that to handle the logic.
Something like this but please enhance
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
new GlideSysAttachment().copy('sn_hr_core_case', current.transferred_from, 'sn_hr_core_case', current.sys_id);
// delete logic
var attachment = new GlideSysAttachment();
var oldHrCaseRef = current.transferred_from.getRefRecord();
attachment.deleteAll(oldHrCaseRef);
})(current, previous);
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
07-31-2025 02:53 AM
Hello Ankur,
Thank you for your prompt response.
Below is the Async BR - Transfer attachments after prediction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2025 08:53 PM
So what's not working?
what debugging did you do?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader