Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please refer below link:

https://community.servicenow.com/community?id=community_question&sys_id=08f807a1db5cdbc01dcaf3231f96...

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi Ankur,

 

I am using the GlideSysAttachment.copy, but it copies all the attachments again n again.

Hi,

just check the script above and it should help you

You can also refer below link:

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

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

quentin_gillet
ServiceNow Employee
ServiceNow Employee

The copyattachment function copies everything. so 2 options as far as I can see

- delete all the attachment on the child before invoking the function (risky as it would delete attachment made on the child directly)

- delete duplicates -> see documentation: Useful attachment scripts

Good luck!