trigger email notification when an attachment is added to an incident

Purushotham1992
Tera Contributor

Hi ,

 

 

Trigger email notification when an attachment is added to an incident working fine but unable send with this body

 

 

1. Attachment by: Person that attached.

2. Attachment Date: [Date/Time]

3. You can view the attachment by clicking the link below.

 

 

4. *[link should take them to the incident.]

 

Purushotham1992_0-1707105047729.png

 

 

 

Event and email Notification created on incident table 

Business rule created on Attachment table 

 

 

Thanks in advance 

1 ACCEPTED SOLUTION

Hello @Purushotham1992 ,

 

Use var t = event.parm2 instead of var t=${event.parm2}

View solution in original post

18 REPLIES 18

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Can you share what you've setup and is not working fine?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

siva krishna M2
Tera Guru

Hello @Purushotham1992 ,

 

Kindly use below script in your after insert business rule;

 

var rec = new GlideRecord('sys_attachment');

rec.addQuery('table_name','incident');

rec.orderByDesc('sys_created_on');

if(rec.next())

{

var user = rec.sys_created_by;

var creator = new GlideRecord('sys_user');

creator.get('user_name',user)

var attachedby = creator.getValue('name');

var createdtime = rec.sys_created_on;

}

gs.eventQueue(event name, current,attachedby ,createdtime )

 

In the notification, Update the body 

 

1. Attachment by: ${event.parm1}.

2. Attachment Date: ${event.parm2}

3. You can view the attachment by clicking the link below.

 

 

4. *[link should take them to the incident.]

 

 

Please click on "Helpful" and "Accept solution" if it works

 

 

 

 

 

Purushotham1992
Tera Contributor

Hai @siva krishna M2 

 

Here we are using one of the parameter for group , how can we use more than two parm at a time and below two

 

3. You can view the attachment by clicking the link below.

 

 

4. *[link should take them to the incident.]


        var incAtt = new GlideRecord('incident');
        incAtt.addQuery(current.table_sys_id,incAtt.sys_id);
        incAtt.addEncodedQuery('assigned_to=');
        incAtt.query();
        if (incAtt.next()) {

            var group = incAtt.assignment_group;
           
            if (incAtt.get(current.table_sys_id)) {

   var createB =current.sys_created_on;

                gs.eventQueue('incident.attachment.add',current,group,createB);

 

Thanks in advance 

Hello Purshotham,

 

  var incAtt = new GlideRecord('incident');
        incAtt.addQuery(current.table_sys_id,incAtt.sys_id);
        incAtt.addEncodedQuery('assigned_to=');
        incAtt.query();
        if (incAtt.next()) {

            var group = incAtt.assignment_group;
           
            if (incAtt.get(current.table_sys_id)) {

   var createB =current.sys_created_on+","+current.sys_created_by;// we are concatenating two variables as single variable using joiner ","

                gs.eventQueue('incident.attachment.add',current,group,createB);

 

In the notification , we can use below script to get two variables from one variable;

var t = ${event.parm2};

var k = t.split(",");

1. Attachment by: k[1]

2. Attachment Date: k[0];