facing issue in Copying attach ments form Incident task to incident

Arjun Kumar Le1
Tera Contributor

Hi every one,

I am have written a script as below  and used it in before insert and update business rule, but i am facing issue with it.
1.it is copying when i attach one time and the next time it is not copying.

2..when i delete attachment in incident task , it is not deleting in incident.

the written script is as below, please let me know what do i need to write in it extra, or do i need to write script in sys attachment table.

var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('sys_id', current.incident);
incidentGr.query();

if (incidentGr.next()) {
// Check if there are attachments to copy
GlideSysAttachment.copy("incident_task", current.sys_id, "incident", incidentGr.sys_id);
})(current, previous);

5 REPLIES 5

Edxavier Robert
Mega Sage

Hi @Arjun Kumar Le1

Instead of copy the attachments  I will suggest to add a related list with the attachments. Please refer to this great article from Jim Coney

 

https://www.servicenow.com/community/developer-blog/tnt-quot-related-attachments-quot-related-list/b... 

Omkar Mone
Mega Sage

Hello Arjun,

 

You might need to write a script on "sys_attachment" table to include your tables.

Amit Verma
Kilo Patron
Kilo Patron

Hi @Arjun Kumar Le1 

 

Can you please try to change the Business rule to after insert/update on incident_task table and see if it works ?

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

same no change, any one can help in it