- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 10:40 AM
When a CSV file with a specific name (something like xyz.csv) is inserted into the Attachment (sys_attachment) table, I would like to send that attachment via email. Can this be accomplished?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 12:32 PM
Thanks your for your suggestions.
I ended up creating an after insert business rule on the sys_attachment table with a condition of current.table_name == 'sc_req_item' and the following script.
(function executeRule(current, previous /*null when async*/) {
var ritmObj = new GlideRecord('sc_req_item');
if (ritmObj.get(current.table_sys_id)) {
gs.eventQueue('sc_req_item.jct.attachment.add', ritmObj, current.file_name);
}
})(current, previous);
This then created the highlighted event which then triggered the notification with the attachment.
I hope this is helpful for others.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 10:45 AM
Hey,
Follow below article to achieve this:
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 10:45 AM
Hi Chrish,
You can create notification on sys_attachment table to make this work? Whom has this to be sent out that may be possibly need some event so that you can pass parameters in gs.eventQueue() accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 11:24 AM
Hi Jaspal,
I created the notification on the sys_attachment table to send when record is inserted and a condition of File Name is xyz.csv. I also checked the Include Attachments" box. The notification is being triggered when a new xyz.csv file is inserted into the sys_attachment table, but that xyz.csv files that triggered the notification is not be attached to the email that is being sent. What am I missing here?
Thanks,
Chris

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 10:53 AM
Hi,
As mentioned by one poster, you can simply create a notification on the attachment table, build conditions as needed, set recipients, and your message, and that's about it. Should hopefully be pretty standard with no code really needed.
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!