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.

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

As @Edxavier Robert mentioned earlier, have you looked at my post: TNT: "Related Attachments" Related List.

 

It is much cleaner than copying/syncing attachments.