- 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-17-2022 07:53 AM
Hi Allen
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-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.