- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2010 05:43 AM
Managed to achieve this with a BR on the sys_email table, before insert:
This also marks the attachment as being sent already so that we don't constantly send again.
//gs.log('getting attachments if any');
var myInc = current.instance;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',myInc);
gr.addQuery('u_sent',false); //look for attachments that haven't been sent
gr.query();
while (gr.next()) {
gr.u_sent = "true"; //mark the attachment as already sent so we don't send again
//gs.log('found ' + gr.table + gr.table_sys_id);
gr.update();
var table = gr.table_name;
}
gs.print ('Looking for attachment');
Packages.com.glide.ui.SysAttachment.copy (table, current.instance, 'sys_email', current.sys_id);
gs.print ('Copied any found attachments to email');