Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to copy attachment from sctask to ritm

Praveen94
Kilo Contributor

How to copy attachment from sctask to ritm

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Praveen,

I assume you want attachment to be copied over from SC Task to RITM when attachment is added

sample BR on sys_attachment; It would be copying all attachments to RITM from SC TASK

BR: after insert on sys_attachment

Condition: current.table_name == 'sc_task'

Script:

var taskRec = new GlideRecord('sc_task');

taskRec.addQuery('sys_id', current.table_sys_id);

taskRec.query();

if(taskRec.next()){

var ritmRec = new GlideRecord('sc_req_item');

ritmRec.addQuery('sys_id',taskRec.request_item);

ritmRec.query();

if(ritmRec.next()){

GlideSysAttachment.copy('sc_task', current.table_sys_id, 'sc_req_item', ritmRec.sys_id);

}

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

20 REPLIES 20

Need to check

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader