Scheduled job is not triggering event for glideaggregate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2018 10:42 PM
I'm new to developing to bear with me.
I am trying to do a daily scheduled job to check the number of hours worked for the current month and if it breaches 7 to trigger an event. I can get the log to come through but the event fails to trigger. Can anyone advise what I did wrong?
Error:
getEventTarget() called with invalid record reference: task_time_worked. for event: deloitte.notification.hours.breached, could have been deleted |
My scheduled job script is below:
for(var i = 0; i< 1; i++){
var agg = new GlideAggregate('task_time_worked');
agg.addAggregate('sum','u_time_in_hours');
agg.setGroup(false);
agg.addQuery('sys_created_on', '>=', 'javascript:gs.monthsAgoStart('+i+')');
agg.addQuery('sys_created_on', '<=', 'javascript:gs.monthsAgoEnd('+i+')');
agg.query();
var count;
while (agg.next())
count = agg.getAggregate('sum','u_time_in_hours');
var limit = '7';
if(count>limit){
gs.log ('Deloitte has worked ' + count + ' hours this month');
gs.eventQueue ('deloitte.notification.hours.breached', agg, '', '');
//gs.print(count);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2018 08:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2018 10:06 PM