- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 05:29 AM
Hello Community,
I'm having a problem with my events getting queued but then they just sit there, and never get processed. Here is more about my configuration...
I have a script include that is triggering an event I made(test.error.event set to use the error_handling queue) and passing along an error object with information about the error. When that event gets triggered, I have a Script Action associated with that event that will create a new incident(from a template) with all of the error information in it. That's the whole process that I am expecting to happen each time the event gets triggered.
What is currently happening, is the incident is not being created. I checked the event logs and noticed my custom events are in there with this state...
I was reading this article → How to create additional event processors? � and this article → Example of events stacked that send the same message � to better understand the lifecycle of the events that get generated. So I created a new event processor(scheduled job that runs every 30 seconds and runs the GlideEventManager('error_handling').process() method) and when I saved this processor to the system, the events in the event log, changed from a state of Ready to the state depicted above. So it appears the method queued the events but has not actually processed them and I cannot figure out why or how to process them? Any suggestions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 06:44 AM
I believe the answer to the problem is in your ternary operators (condition ? expr1 : expr2). There may need to be additional parenthesis added. my hunch is to focus on the populateDescription function with the way you are concatenating text together with ternary operations within.
for testing, try commenting out the line: incident.description = populateDescription(obj);
in any case, I think you will need to break some of the ternary operations up or add additional parentheses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 06:07 AM
Here is the content from the event showing Parm1 and Parm2....at this point, Parm1 is a JSON string
and here is the content of the script action associated with the event...
var json = new JSON();
var parameterOne = (isJSON(event.parm1) == true) ? json.decode(event.parm1) : event.parm1;
createIncident(parameterOne);
function createIncident(obj) {
gs.log("Checkpoint 1");
try {
var incident = new GlideRecord('incident');
incident.initialize();
incident.caller_id = (typeof(obj) == "object") ? gs.getUser().getUserByID(obj.user.toString()).ID : gs.getUserID();
incident.u_affected_user = (typeof(obj) == "object") ? gs.getUser().getUserByID(obj.user.toString()).ID : gs.getUserID();
incident.short_description = (typeof(obj) == "object") ? obj.message : obj.toString();
incident.priority = determinePriority((typeof(obj) == "object") ? obj.severity.toString() : "2").toString();
incident.description = populateDescription(obj);
incident.applyTemplate("Script Error Handling");
var id = incident.insert();
} catch (error) {
gs.log("An error occurred when attempting to generate an incident due to an error in the system.");
}
}
function populateDescription(obj) {
gs.log("Checkpoint 2");
try {
if (typeof (obj) !== "object") {
return obj;
}
var description = "This incident was generated from an error that has occurred in the system. Details can be found below.\n\n";
description += "Script Type : " + ((obj.hasOwnProperty('scriptType') == true) ? obj.scriptType : "Unable to determine the script type.") + "\n";
description += "Script Name : " + ((obj.hasOwnProperty('scriptName') == true) ? obj.scriptName : "Unable to determine the script name.") + "\n";
description += "Error Message : " + obj.message.toString() + "\n\n";
description += "Severity : " + ((obj.hasOwnProperty('severity') == true) ? obj.severity : "Unable to determine the severity of this error.") + "\n";
description += "User : " + ((obj.hasOwnProperty('user') == true) ? obj.user : "Unable to determine the user that triggered this error.") + "\n\n";
description += "Record Information" + "\n";
description += "Table : " + ((current !== null) ? current.sys_class_name.getDisplayValue() : "There is no record associated with this error.") + "\n";
description += "Number : " + ((current !== null) ? current.number.toString() : "There is no record associated with this error.") + "\n";
description += "Unique ID : " + ((current !== null) ? current.sys_id.toString() : "There is no record associated with this error.") + "\n";
if ((current !== null) && (current.sys_class_name == "sc_req_item")) {
description += "Item : " + (!current.cat_item.nil()) ? current.cat_item.getDisplayValue() : "Unable to determine what item was requested.";
}
return description;
} catch (error) {
gs.log("An error occurred while attempting to populate the description of an incident being created due to an error in the system.");
}
}
function determinePriority(severity) {
gs.log("checkpoint 3");
try {
if (!severity) {
return "No severity provided! Unable to determine priority!";
}
var priority = 0;
switch (severity.toString()) {
case "1":
priority = 2;
break;
case "2":
priority = 3;
break;
case "3":
priority = 4;
break;
default:
priority = 3;
break;
}
return priority;
} catch (error) {
gs.log("An error occurred while attempting to determine the priority of an incident being created due to an error in the system.");
}
}
function isJSON(object){
gs.log("checkpoint 4");
try {
var JSONObject = json.decode(object);
if ((typeof(JSONObject) === "object") && (JSONObject !== null)) {
return true;
}
return false;
} catch (error) {
throw error;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 06:44 AM
I believe the answer to the problem is in your ternary operators (condition ? expr1 : expr2). There may need to be additional parenthesis added. my hunch is to focus on the populateDescription function with the way you are concatenating text together with ternary operations within.
for testing, try commenting out the line: incident.description = populateDescription(obj);
in any case, I think you will need to break some of the ternary operations up or add additional parentheses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 01:07 PM
After trying to debug that particular method, I found that it would not work unless I commented out that entire method including the call to that method(line 14). So, I've re-factored that entire method without using ternary operators and using IF statements instead. Now the script is a little longer but, it certainly works. Thanks for the assist.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016 01:13 PM
Cool!
-Jon
Sent from my iPhone