Sending an email notification when an attachment is added to an Incident record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 08:49 AM
Thanks to
Secondly and more importantly I would like the outgoing email generated from the notification to include the attachment in this case Email.png.
As I'm not much of a coder I would greatly appreciate any help.
Any questions please ask.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 05:32 AM
can you share the screenshot of the email?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 05:37 AM
Hi
Please refer the approach mentioned by Goran using Flow designer on the same topic which will include the attachment and will not require code here:
https://www.youtube.com/watch?v=b_l5pOHKmVY
This should work for you.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 05:52 AM
Hi
Also would like to add, after reviewing your existing set up, you need to make the below changes:
1) Create a After Insert Business Rule on Attachment Table and use the script below:
BR Details:
Table: Attachment(sys_attachment)
When: After Insert
Condition: Table Name is incident
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.eventQueue('Event Name',current,current.file_name,current.sys_id);
})(current, previous);
Screenshot of BR for reference:
Now in your Notification, please make sure to check the below check boxes under whom will receive tab as shown below:
1) Parm 1
2) parm 2
3) Send to Event Creator
Include Attachment checkbox under 3rd tab of Notification form:
Now Navigate to the module "Notification Email Script" as shown below:
Click on New and use the script below:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var myStringArray = event.parm2.toString();
var sys = current.sys_id;
//This queries the sys_attachment table for all attachments where the table_sys_id is the sys_id you used above.
var grSysAtt = new GlideRecord('sys_attachment');
grSysAtt.addQuery('table_sys_id', sys);
grSysAtt.query();
while (grSysAtt.next()) {
var asys = grSysAtt.sys_id;
//This if statement checks the attachments that you used in myStringArray and makes sure that it only grabs those attachments.
if (myStringArray.indexOf(asys) >= 0) {
var content = new GlideSysAttachment().getContentStream(grSysAtt.sys_id);
new GlideSysAttachment().writeContentStream(current, grSysAtt.getValue('file_name'), grSysAtt.getValue('content_type'), content);
template.print("File name" + grSysAtt.getValue('file_name'));
}
}
})(current, template, email, email_action, event);
Now just call this Notification Email script in your notification using the syntax below:
${mail_script:Notification Email Script Name here}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 05:53 AM
Hi
I have shared both approach using Code via Business Rule as well as using No code approach using Flow Designer. Please try and let me know if you are still stuck on this.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke