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
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  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

18 REPLIES 18

@Clement_V 

Can you post a new question with all the details and tag me there as this is an old thread?

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

Sorry, I didn't quite understand the request.
I'll do that.

Magali Modugno
Kilo Contributor

Hey @Ankur Bawiskar ,
I'm using your code and it works fine but the attachment can only be seen from Notes or Activity Log and not from "Manage Attachments". If I manually upload an attachment directly in the destination record form, it appears normally.
Do you know how to solve this issue?


Thanks!

Need to check

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