How to trigger mail whenever attachment is added for incident

ankurpd001
Tera Contributor

I want to know how to trigger email whenever i add attachment to incident ticket.
Mail should be trigger to "Caller"

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

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,


View solution in original post

14 REPLIES 14

ccajohnson
Kilo Sage

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,


Very well documented

Thanks

Thank you ! It worked.

Thank you ! It worked.