Add attachments to Task via script
Add attachments to Task via script
So i wanted to add all the attachments that comes from the RITM the users create when opening a case from the portal. But i wanted to do it from a script which fits in a broder module im working on. So Servicenow have a convient way of doing that using the “GlideSysAttachments” API
I works like this, you query the attachments from the source table and copy all the attachments to the target table
_moveAttachments: function(table,ritmSysID,taskSys) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', ritmSysID);
gr.query();
if (gr.next()){
GlideSysAttachment.copy(table, ritmSysID, 'sc_task', taskSys);
}
}
This script is for a script include and the target table will always be sc_task in this case, but you could just change that to another table or set it as argument in the function signiture