How to copy attachment from Incident task to incident

Khasim Shaik1
Kilo Expert

Hi Team,

How can we copy attachments from incident task table to incident table? 

Please help on this 

 

Thanks,

Khaism

1 ACCEPTED SOLUTION

Varsha21
Giga Guru

Hi,

write BR on incident_task table like after insert/update

if you need you can write condition like 

incident isnotempty

and code like bellow,

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr=new GlideRecord('incident');
	gr.addQuery('sys_id',current.incident);
	gr.query();
	//gs.addInfoMessage(gr.getRowCount());
	if(gr.next())
		{
		GlideSysAttachment.copy("incident_task",current.sys_id,"incident",gr.sys_id);
		}
	gr.update();

})(current, previous);

code ll copy attachment to related incident.

 

varsha

View solution in original post

8 REPLIES 8

Can you share your code?So that i can suggest you something.

 

 

Regards,

Pooja

Hi Pooja,

Please check the below code .

 

BR on Incident task table:

after: update

var task = new GlideRecord('incident');
task.addQuery('sys_id', current.incident);
 task.query();
 while(task.next()){
GlideSysAttachment.copy('incident_task',current.incident, 'incident', current.sys_id);
}

 

Thanks,

Khasim

Varsha21
Giga Guru

Hi,

write BR on incident_task table like after insert/update

if you need you can write condition like 

incident isnotempty

and code like bellow,

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr=new GlideRecord('incident');
	gr.addQuery('sys_id',current.incident);
	gr.query();
	//gs.addInfoMessage(gr.getRowCount());
	if(gr.next())
		{
		GlideSysAttachment.copy("incident_task",current.sys_id,"incident",gr.sys_id);
		}
	gr.update();

})(current, previous);

code ll copy attachment to related incident.

 

varsha

Thank you Varsha , it's working