Firing Events from scheduled Jobs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2015 01:33 PM
I am trying to figure out the 'best' method to notify/ re notify if changed users of an activity. I have another post where i was trying to do this with a workflow but I am thinking a scheduled job might be the safest bet.
I am trying to fire an event from a scheduled job when the follow up date is within 1 minute. I am running the job every 2 minutes and I am checking if the notification field is within 1 minutes or less and the same field and its not greater than 2 minutes ago is there a better method of checking this notification field to trigger this scheduled job that fires off this email?
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.addQuery('state',4)
gr.query();
gr.next();
while(gr.next()){
if ('u_notification', '=<', gs.minutesAgo(1) && 'u_notification', '!=>', gs.minutesAgo(2)); {
//set state
gr.addQuery('state',1)
// Fire event to send email
gs.eventQueue("incident.notification", current)
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2015 01:44 PM
You have to say gr.u_notification, not 'u_notification'.
You may want to look at creating a sys_trigger that will fire the event instead of the scheduled job.
Your set state would be
gr.state = 1;
gr.update();
gs.eventQueue("incident.notification", gr, null, null);
So,
if (gr.u_notification >=, gs.minutesAgo(1) && gr.u_notification <= gs.minutesAgo(2)); {
//set state
gr.state = 1;
gr.update();
// Fire event to send email
gs.eventQueue("incident.notification", gr, null, null);
}
Or something like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2015 01:50 PM
Hi,
In addition to what Mike already commented, make sure that the event: incident.notification is associated to the notification that you want to trigger.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2015 02:12 PM
I thought scheduled jobs were stored in the sys_trigger table. I checked the table and the scheduled job is in the table. is there something else i need to be looking at/missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2015 02:16 PM