Synchronize attachments between Case and Incident

Christophe
Tera Contributor

Our customers created case via the web portal. Our engineers work in the incident. All the updates that should be visible for the customer are synchronized between case and incident. When a customer adds an attachment to the case, it is not visible in the incident. How can I make this work? I checked the forum and the documentation, but was not really able to find a solution. Thank you in advance for your help!

1 ACCEPTED SOLUTION

My pleasure and please start working on scripting by joining the developer's learning on https://developer.servicenow.com.

Kindly,mark the answer as correct if this helps you out so,this questions could be considered as closed for other community members.

Regards,

Munender

View solution in original post

21 REPLIES 21

Naveen Velagapu
Mega Guru

you can use GlideSysAttachment.copy(sourceTable ,source Sysid,taregt table ,target sysid ) to copy attachments from case table to incident table. May be you can write a bussiness rule on sys_attachment table , copy to incident based on relation between case / incident by evaluating conditions. In the same you can handle delete attachments as well. 

If you  think of script actions , use attachment.uploaded , attachment.deleted and write necessary copy and delete scripts

 

https://docs.servicenow.com/bundle/jakarta-application-development/page/app-store/dev_portal/API_ref... 

 

Mark helpful if this is  helpful for you.

 

Munender Singh
Mega Sage

Hi,

write a after Business rule on the case table:

script:

var incGr = new GlideRecord('incident');

 

incGr.addQuery(<'field name which in on incident and refer the table(case) of which you want to copy the attachment'>, current.table_sys_id);

 

incGr.query();

 

if(incGr.next())

 

{

 

  GlideSysAttachment.copy('<soruce tabele name>', current.table_sys_id, 'incident', incGr.sys_id);

 

}

Regards,

Munender

I have one more question. What do you mean by "<'field name which in on incident and refer the table(case) of which you want to copy the attachment'"?  The cases are on table "sn_customerservice_case" and the incidents on table "incident" What do you mean by field name? 

Hi,

This means a reference field of case table i.e. the field displaying the case table.

eg. on incident form caller name is field which is showing user name hence,this field is on incident and refer the user table

 

Regards,

Munender