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

HarshTimes
Tera Guru

Sanjay Bagri1
Tera Guru

Hi ,

you can go once below link this links definitely give you solution: 

in below links code you can set the according to requirement table & field name .

https://community.servicenow.com/community?id=community_question&sys_id=b6a5c242db6417884816f3231f961953&view_source=searchResult

 


If my suggestion helped then please Mark the correct & helpful.
so other community members can benefit from this information.

Thanks
Sanjay Bagri

||DxSherpa Tech. ||

Pooja Mallikarj
Kilo Sage

Hi,

You can use below function to copy attachment from one table to another table

GlideSysAttachment.copy('sourcetable', 'sys_id', 'destinationtable', 'sys_id')  Make sure you need to use this in after Insert Business rule in the Attachment

You can use below function to copy attachment from incident task table to incident table

GlideSysAttachment.copy('incident_task' ,current.sys_id ,'incident' ,'sys_id');

 

please mark correct/helpful if it helps for you.

Regards,

Pooja

 

Khasim Shaik1
Kilo Expert

Hi Pooja,

 

It was not working, we have to query incident task table ? 

 

Thanks in advance !!

 

Regards,

Khasim