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

CapaJC
ServiceNow Employee
ServiceNow Employee

Instead of stopworkflow(false) try setWorkflow(false)

(note the camelCase with the capital "W")


Yes. This solution is working as well. Thanks once again.

Want to know the implications of stopping the workflow when the script action is running.

My code looks like below:

var isWorkflow = !current.wf_activity.nil();

if(isWorkflow) {
grCMDB.setWorkflow(false);
}

grCMDB.update();

if(isWorkflow) {
grCMDB.setWorkflow(true);
}

Can you think of any scenarios which could be impacted because of the stopping of workflow in the script action?