Send a notification on Inbound email action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 04:59 PM
I have created an Inbound action on incident table.
Where, its matching the condition on incident, if the incident is found, then do the updates from inbound. This works fine.
Now, I just want to sent an email notification if the incident is not found. I was just wondering the following solution will work or not:
1. I am thinking of registering a new event and then using that in my else condition of the same inbound action,
2. which will then fire the notification. Is that going to work without any errors?
Please suggest if this is the best or do we have any other best option as well.
Thanks in advance!
Cheers!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 05:40 PM
Hi Jyo,
Yes it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 07:40 PM
Hi Pradeep,
Thanks for your reply!
I have tried it but have some issues with Inbound... its not executing correctly.
1.I want to do if the incident number is not found, then trigger email which I am doing using "task.no.snreference.found" in the last.
2. If the incident number matches but abc_reference_number is already populated with some value, now its again trying to update the same incident's "abc_reference_number " field with different value which is coming via external_reference.
Here is my code:
var status = email.body.status;
var targetRec = new GlideRecord('incident');
targetRec.addQuery('number', email.body.reference_number);
//targetRec.addQuery('abc_reference_number', email.body.external_reference);
targetRec.query();
//If the incident has been found
if (targetRec.next()) {
if (targetRec.abc_reference_number != "" || targetRec.abc_reference_number != "email.body.external_reference")//This is working even if the reference number is empty
{
gs.eventQueue("task.no.externalref.found", targetRec, email.body.external_reference, email.body_text);
}
else {
targetRec.abc_reference_number = email.body.external_reference;
var worknote = email.body.worknotes;
targetRec.work_notes = worknote.replace(/<cr>/g, "\n");
//targetRec.work_notes = String(email.body.worknotes);
if(status == "Resolved" || status == "Closed")
{
targetRec.state = 6;
targetRec.u_cause_code="Unknown";
targetRec.u_resolution_code="Resolved By Third Party";
targetRec.u_actual_affected_ci= targetRec.u_technical_service;
}
else {
targetRec.state =status;
}
targetRec.update();
}
}/*This code is not working
else {
gs.eventQueue("task.no.snreference.found", targetRec, targetRec.number, email.body_text);
}*/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 11:04 PM
Hi Jyo,
gs.eventQueue(Name,Record,Param1,Param2); Can you please check param passed in above code you have shared.
Param1 :
Passes a string value. Notification events pass the Sys ID of the user with the gs.getUserID() method. Other scripts can reference this string value as parm1 using the format ${event.parm1}.
Param2 :
Passes a string value. Notification events pass the user name with the gs.getUserName() method. Other scripts can reference this string values as parm2 using the format ${event.parm2}.
Events and Email Notification - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 11:05 PM
Also make sure send to event creator checkbox is set to true and check event logs table to see whether event is fired or not.