Notify the fulfiller when a customer replies to an email

Nicholas Hromya
Mega Guru

Hello everyone,

When a customer replies to an incident notification, I want a notification (additional comments) to go to the assigned fulfiller.

I thought I found the solution here:

Solved: Send notification when user responds to email noti... - ServiceNow Community

 

However, that simply has the inbound action - not active - saved - active.  This didn't work for me.

I also tried adding an event to the inbound action Update Incident (BP).

as

gs.eventqueue(incident.comments), current, email.origemail, email.body_text;

I see the inbound email, I see the inbound action triggered, but I don't see the event triggered.

 
I think my gs.eventqueue is wrong.

 

1 ACCEPTED SOLUTION

Rafael Batistot
Kilo Patron

hi @Nicholas Hromya 

 

your gs.eventQueue syntax is off. In ServiceNow, gs.eventQueue() always takes 4 parameters in a fixed order:

 

 
gs.eventQueue(eventName, gr, parm1, parm2);
  • eventName → string (the name of the event you registered in System Policy > Events > Registry)

  • gr → GlideRecord of the record the event is about

  • parm1 (optional) → string parameter you can pass (shows up as event.parm1)

  • parm2 (optional) → string parameter you can pass (shows up as event.parm2)

May you try use in this format 

gs.eventQueue("incident.reply.received", current, email.origemail, email.body_text); 

 

View solution in original post

3 REPLIES 3

Rafael Batistot
Kilo Patron

hi @Nicholas Hromya 

 

your gs.eventQueue syntax is off. In ServiceNow, gs.eventQueue() always takes 4 parameters in a fixed order:

 

 
gs.eventQueue(eventName, gr, parm1, parm2);
  • eventName → string (the name of the event you registered in System Policy > Events > Registry)

  • gr → GlideRecord of the record the event is about

  • parm1 (optional) → string parameter you can pass (shows up as event.parm1)

  • parm2 (optional) → string parameter you can pass (shows up as event.parm2)

May you try use in this format 

gs.eventQueue("incident.reply.received", current, email.origemail, email.body_text); 

 

Nicholas Hromya
Mega Guru

Thank you for the example!  That really helped.  I did put the ; at the end, but I needed not do that as I put it in the if statement near the end as

   
    if (gr.canWrite())
    gs.eventqueue("incident.commented", current, email.origemail, email.body_text);
        gr.update()
        ;
I had to remove the semi colon at the end of the gs.eventqueue (I think that's what made it work).
 

Nicholas Hromya
Mega Guru

Hello @Rafael Batistot (and others).

Thank you for helping me correct the syntax.  However, the email is NOT going to the customer; it is going to the fulfiller. 

Do I have my gs.eventqueue in the wrong area (in the wrong part of the If statements?) of the inbound action?

 

This is how my inbound action looks now:

 
gs.include('validators');

if (current.getTableName() == "incident") {
   
    var gr = current;
   
    if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
        gr = new Incident().reopen(gr, email) || gr;
   
    gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
   
    if (gs.hasRole("sn_incident_write") || gs.hasRole("itil")) {
        if (email.body.assign != undefined)
            gr.assigned_to = email.body.assign;
       
        if (email.body.priority != undefined && isNumeric(email.body.priority))
            gr.priority = email.body.priority;
    }
   
    if (gr.canWrite())
    gs.eventqueue("incident.commented", current, email.origemail, email.body_text)
        gr.update()
        ;
}
 
Thank you in advance.
Nick