- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 04:20 AM
I want to know how to trigger email whenever i add attachment to incident ticket.
Mail should be trigger to "Caller"
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2018 01:28 PM
Attachments are stored on a separate table called Attachment. There are details on this Attachment record that point to the table that this attachment is related to. Since you want to send an email, here is what you need to do:
1. Create an Event to use with your notification:
A. Navigate to System Policy > Registry.
B. Click New to create a new Registry. Here are the details for the Event Registry record:
Event name: incident.attachment.add
Table: Incident [incident]
Description: Used to send a notification when an attachment is added.
Fired by: Business Rule
2. Create a Business rule to trigger the event:
Name: Send Event for Incident Attachment add
Table: Attachment [sys_attachment]
Advanced: true
Description: Sends an event when an attachment is added to the Incident table
When: after
Order: 100
Insert: true
Update: false
Delete: false
Query: false
Condition: current.table_name == 'incident'
Script:
(function executeRule(current, previous /*null when async*/) {
var incObj = new GlideRecord('incident');
if (incObj.get(current.table_sys_id)) {
gs.eventQueue('incident.attachment.add', incObj, current.file_name);
}
})(current, previous);
3. Create your notification:
Name: INC-Attachment Added
Table: Incident [incident]
Send when: Event is fired
Event name: incident.attachment.add
Users/groups in fields: Caller
Subject: Attachment ${event.parm1} has been added to Incident ${number}
Let me know if you have any questions,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 01:37 PM
Yep, event registry created. Followed the exact steps, just changed the incident table to sc_req_item and then modified that script. Does that script look ok?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 02:12 PM
The script syntax looks correct. Just make sure your script is on the attachments table and that the Condition on the Business Rule is also indicating the sc_req_item table.
If you want to test the script. You can do so through Scripts - Background. Just find a record in the attachment table with sc_req_item as the table name. Then right-click on the name and select Copy sys_id. Then go to Scripts - Background and run code similar to the following:
var current = new GlideRecord('sys_attachment');
current.get('04ba27f0db81a850ecbea4cb0b9619d8');
var itemObj = new GlideRecord('sc_req_item');
if (itemObj.get(current.table_sys_id)) {
gs.eventQueue('sc_req_item.attachment.add', itemObj, current.file_name);
}
Just be sure to change the sys_id value in the current.get statement to the one you just copied.
This way you can verify that the event is triggered.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 07:48 AM
For future people who may read this there are events that are triggered now when attachment actions are taken. They are
attachment.uploaded
attachment.read
attachment.deleted
Parm1 will be the table and Parm2 will be the record that the attachment was added to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 03:36 PM
Hey Drew
I've seen these, can they be used as they are, they don't have a table specified and firing record seems hard to locate?
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 07:16 AM
Last I checked the event is triggered for the sys_attachment table and Parm1 has the table and Parm2 has the sys_id of the record that the attachment is attached to. So that should be enough to write a script to do what ever is needed.