Need to copy attachment from SCTASK to RITM table

Dhanalakshmi D
Tera Expert

Hi,

 

I have a requirement of copying attachments from sctask to ritm table and below is the business rule I have tried but this added attachment thrice and even I need to avoid duplicate attachments.

Please someone could help!

 

Table - sys_attachment

 when to run - before, on insert and update.

var taskAtt = new GlideRecord('sc_task');
taskAtt.addQuery('sys_id', current.table_sys_id);
taskAtt.query();
if(taskAtt.next()){
var reqAtt = new GlideRecord('sc_req_item');
reqAtt.addQuery('sys_id',taskAtt.request_item);
reqAtt.query();
if(reqAtt.next()){

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

 

 

Thanks

2 ACCEPTED SOLUTIONS

Dhanalakshmi D
Tera Expert

Hi Gunjan,

 

This will delete existing attachment which is already present in RITM, which should not be where it should only copy the attachments from SCTASK.

 

Thanks

View solution in original post

Hi @Dhanalakshmi D ,

Then you can try below solution:-

https://www.servicenow.com/community/developer-forum/copy-newest-attachment-only-from-task-to-ritm/m...


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

5 REPLIES 5

Hi @Dhanalakshmi D ,

Then you can try below solution:-

https://www.servicenow.com/community/developer-forum/copy-newest-attachment-only-from-task-to-ritm/m...


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy