Move attachments from HR case to HR task without duplicate attachments

Ashish71
Tera Contributor

Hi,
I have a requirement where we need to move all the attachments from HR case to all associated HR tasks without duplicate attachments get copied. I have tried with before/after BR [insert and update] on HR Case table but it is not working. No attachments are moved to the HR task record. Below code I have used:

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);
}
3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Do you want to move each attachment to each associated HR Task, or copy them?  Do you want this to happen as the attachment is added to the HR Case, or when a HR Task is created or when?  

 

I wouldn't recommend any such activity due to database bloat and out of sync issues.  Just create a new Related List to display on the HR Task record that shows the attachments on the HR Case.

Satyam123
Tera Contributor

Hi @Ashish71 did you find something on this, if yes please let me know

phgdet
Mega Sage

Hi Ashish71
Have you check the scope of your script? Some cases, for instance, HR LE need to approach from its own scope.