how to copy attachment from one task to another?

Ujjwala1
Tera Contributor

Hello Experts,

 

We have received a requirement from client , we want the attachment added by task handler on sc_task table should get copied on another task so that concerned team can download the attachment added and do the needful

 

How can we achieve this?

 

 

All suggestions are welcome here,

 

 

Thank you,

Ujjwala

1 ACCEPTED SOLUTION

manjusha_
Kilo Sage

@Ujjwala1 

 

 

Refer this sample code:Create before insert business rule

var task = new GlideRecord('sc_task');

task.addQuery('request_item',current.request_item);//check proper names for Ritm reference field on sc_task record

task.query();

if(task.next()){

  1. GlideSysAttachment.copy('sc_task', current.sys_id, 'sc_task',task.sys_id);

}

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact

Thanks and regards,

Manjusha .

 

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Yes you can,

in the sys_attachment table you need to find the table (sc_task in your case) and the sys_id of the record the attachment is attached.

Then you need to create new record with your new table and new sys_id - basically copy the previous record and insert new one with these 2 things changed.

manjusha_
Kilo Sage

@Ujjwala1 

 

 

Refer this sample code:Create before insert business rule

var task = new GlideRecord('sc_task');

task.addQuery('request_item',current.request_item);//check proper names for Ritm reference field on sc_task record

task.query();

if(task.next()){

  1. GlideSysAttachment.copy('sc_task', current.sys_id, 'sc_task',task.sys_id);

}

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact

Thanks and regards,

Manjusha .

 

Hi,

Thanks for replying 

On which table I should write this BR?

 

Thanks

@Ujjwala1 

 

The table on which you are creating the task -sc_task(i thought you are using sc_task so i written code as per that )

Thanks,

Manjusha Bangale