How to move attachment from HR case to HR task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:10 PM
Hi All,
I have to move attachment from HR case to HR task when HR case status is "work in Progess" . I have write a BR on c HR case table but it is not working any more. could you please look into this ??
GlideSysAttachment.copy("sn_hr_core_global_mobility",current.parent,"sn_hr_core_task", current.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:17 PM
Hello,
This has working code
https://community.servicenow.com/community?id=community_question&sys_id=2cf37c4bdbe7c110770be6be13961962
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 11:28 PM
Hi,
I would suggest not to copy files as it will increase table size of sys_attachment.
Instead check this blog
"Related Attachments" Related List
If you still require then update your script as this to copy files to all HR Tasks under this HR Case
BR: HR Case Table
Condition: HR case status is "work in Progess"
var gr = new GlideRecord("sn_hr_core_task");
gr.addQuery("parent", current.sys_id);
gr.query();
while (gr.next()) {
GlideSysAttachment.copy(current.getTableName(),current.sys_id,"sn_hr_core_task", gr.sys_id);
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:39 AM
Hi Ankur,
we have to write this piece of code in which table ?? Please once.
var gr = new GlideRecord("sn_hr_core_task");
gr.addQuery("parent", current.sys_id);
gr.query();
while (gr.next()) {
GlideSysAttachment.copy(current.getTableName(),current.sys_id,"sn_hr_core_task", gr.sys_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 04:39 AM
Hi,
you want files to copy when HR case status is "work in Progess"
So it will be on HR Case table.
I already covered it in my earlier response.
If my response helped please mark it correct and close the thread so that it benefits future readers.
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader