getEventTarget() called with invalid table name:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2012 11:20 AM
I have created a business rule which checks periodically if a change request is still open 24 hours after its end_date. If so it fires an event that sends out an email notification.
The problem I am having is when the business rule runs and fires the event, I get a warning that states the following:
getEventTarget() called with invalid table name: f82f5a390a0a3c9f00de405e6e670cce for event: change.overdue
Business Rule Script
NotifyChangeOverdue();
function NotifyChangeOverdue() {
var now = gs.nowDateTime();
var gr = new GlideRecord('change_request');
gr.query();
while (gr.next()){
gs.log("Overdue Notification sent for Change # " + gr.number);
gs.log("Overdue Notification sent for Change # Type:" + gr.type + " -- Change Owner:" + gr.assigned_to.name);
gs.eventQueue("change.overdue", gr.sys_id, gs.getUserID(), gs.getUserName());
}
}
The event queue then shows that it has run the script that it has an invalid table.
The event is registered with the change_request table. Also the business rule is configured to run against the change_request table. I am not seeing what else I need to do in creating my custom event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2012 11:31 AM
check if table assigned to the event "change.overdue" and it's corresponding notification.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2012 11:46 AM
I have verified the following:
change.overdue is registered/assigned to the change_request table
BR rule that executes the change event is also assigned to change_request table
Email notification built for event is assigned to change_request table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2012 11:59 AM
Hi,
Try this :
gs.eventQueue("change.overdue", current, gs.getUserID(), gs.getUserName());
It is getting confused with the sys_id.
ND

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2012 12:50 PM
Well that did fix it. However, that doesn't make a lot of sense to me.
First the instructions listed here:
http://wiki.servicenow.com/index.php?title=Events_and_Email_Notification#Building_a_Script
Clearly state the following:
The record referenced when the condition in the script evaluates to true. Usually this is expressed as current, meaning the record on which the business rule is working. If the business rule is being triggered as part of a scheduled job, use a GlideRecord argument in its place.
The business rule is being triggered as part of a scheduled job. So my code, in theory, should be correct. However, as my testing has shown "current" is the solution.
Thank you for your advice and your help. We have easily spent 12 hours of development on this already.