Event handling - Need to run a script when the event is fired

gautamchawak
Kilo Explorer

There is an event created on discovery_device_history table. Want to take some action when the event is fired.
I have already performed the following steps:
1. Register the event (event is registered in table : sysevent_register)
2. Fired the event in the business rule (gs.eventQueue("discovery.device.complete", current, current.sys_id, current.status));
3. Handle the event that is fired (Don't want to send notifications but have to run a script that performs certain actions)

Am stuck with step3. How do I run a script that performs certain action when a event is fired?

11 REPLIES 11

DubeyN
Mega Expert

Create a scehduled job and call the job in business rule instead of event (never did same using event, but I am sure it's possible via event as well).

var rec = new GlideRecord('sysauto_script');
rec.get('name', 'YOUR_JOB_NAME_HERE');
Packages.com.snc.automation.TriggerSynchronizer.executeNow(rec);

ND


Is there a way directly to read/process the event when it is fired?


DubeyN
Mega Expert

You can check it at "Events" System logs. It will give you all the details regarding the event and you can reprocess the event from there.


So you mean to create a scheduled job to read/process the entries for that event name from "sysevent" table. Is this correct understanding?