We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

jsjsnaN
Tera Contributor

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

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

https://www.servicenow.com/community/developer-forum/how-to-trigger-mail-whenever-attachment-is-adde...

 

 

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}

 

 

cc:  @ccajohnson 

 
*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

GlideFather
Tera Patron

Hi @jsjsnaN,

 

attachments are stored to [sys_attachment] table, but what's your real requirement?

 

Is this to learn or a real task to do? Because attachments can be added, removed and re-added again.. it will flood you with so many unwanted emails... what is is good for?

 

_____
100 % GlideFather experience and 0 % generative AI