attachment sync from parent to child HR case & vice versa

Community Alums
Not applicable

Can anyone please help me with the attachment sync,

I have written a BR for attachments to move from child to parent, which is attaching all of those if a new attachment is done on the child case.

I need only the latest once.

table: sys_attachment

after, insert and update

 

(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord(current.table_name);
gr.get(current.table_sys_id);

if(gr.parent){

GlideSysAttachment.copy(current.table_name, current.table_sys_id, gr.parent.getTableName(), gr.parent);

}

})(current, previous);

Please help in syncing the attachments from parent to child hr cases.

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi Palak,

Kindly refer to this link which allows you to copy 1 attachment from 1 record to another.

https://community.servicenow.com/community?id=community_article&sys_id=633352e5db327b402be0a851ca961...

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

View solution in original post

8 REPLIES 8

Slava Savitsky
Giga Sage

By the way, it is possible to display attachments from the parent record in its child records (and vice versa) as a related list, in which case there is no need to copy anything and you don't end up with tons of duplicate data.

Community Alums
Not applicable

Hi Slava,

I am not using related list as we need to show the attachments in the activity logs, on the SP.

 

asifnoor
Kilo Patron

Hi Palak,

Kindly refer to this link which allows you to copy 1 attachment from 1 record to another.

https://community.servicenow.com/community?id=community_article&sys_id=633352e5db327b402be0a851ca961...

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

Community Alums
Not applicable
Hi Asif, This has been of great help... This almost done, but causing some issues in scoped application... I would like to thank you alot for your extended help. :)