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

Hi,

As i mentioned earlier,I have check this by running on my personal instance,so version won't be a problem.

As I tested by copying attachments from problem to incident,Their could be some problem in the dictionary names which we ar eusing in our code.Please check whether you have selected the correct condition for when to run also.

If not able to get it please share the code .

 

Regards,

Munender 

It works!!! 😄 I had to use the name of the table and not the label name of the table. Now I just have to make it possible that the attachment is removed from the incident when it is removed from the case.  Once more, thank you very much for your help!

Yah,we use only the dictionary name of all fields and table not label name for scripting.

My pleasure

Munender

Hello Munender,

I was trying to do the copying of the attachment the other way around, so from the incident to the case. I changed a few things in the script, but I seems that I guess I was thinking to simple.

1.Write a business rule on sys_attachment table

2.The type of business rule is after and action is on insert/update

3.When to run -->table name is incident


4.Script would be:

var incgr = new GlideRecord('incident');
incgr.addQuery('sys_id',current.table_sys_id);
incgr.query();
if(incgr.next()){

var Gr = new GlideRecord('sn_customerservice_case');
Gr.addQuery('number',incgr.sys_id);
Gr.query();


if(Gr.next())
{

GlideSysAttachment.copy('incident',incgr.sys_id,'sn_customerservice_case',Gr.sys_id);
Gr.update();
}
}

Christophe
Tera Contributor

Thank you guys. You rock!!!