Add attachment to outbound email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 04:46 PM
Hi all,
I want to trigger an outbound email when an attachment is added to a particular type of task, and I want the attachment to be included in the email (but only the latest attachment that's just been added to the task - NOT all attachments that may have been added previously as well).
I have a business rule that runs on the sys_attachment table itself, with a condition that specifies the particular type of task. The business rule generates an event that triggers the email notification. So, in the context of that email notification, 'current' passed in on the event is actually the attachment record itself. Is there a way I can script to include that specific attachment in the outbound email that gets generated?
Thanks for any pointers,
Jamie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 03:37 PM
Just for completeness, this is the code for the second business rule that moves the attachment back. 'u_2e2_task3' is a table extending task:'u_2e2_task3
var attchmt = new GlideRecord('sys_attachment');
attchmt.get(current.instance);
attchmt.table_name = 'u_2e2_task3';
var emailEvent = new GlideRecord('sys_email_log');
emailEvent.addQuery('email', current.sys_id);
emailEvent.setLimit(1);
emailEvent.query();
emailEvent.next();
var evnt = new GlideRecord('sysevent');
evnt.get(emailEvent.event);
var tpNumber = evnt.parm1; //this is the 'number' of the task the attachment was originally added to.
var tpTask = new GlideRecord('u_2e2_task3');
tpTask.get('number', tpNumber);
attchmt.table_sys_id = tpTask.sys_id;
attchmt.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 06:17 AM
Hi Jamie, hope you're well.
Alas this did not work for me.
I do not appear to be able to get the GlideRecord('sys_email_log') look up to recognise the sys_id of the email i am trying to query it with.
Any thoughts on what might be stopping the GlideRecord recognising current.sys_id?