My Business rule triggers the Event but my WF Wait for Event doesn't continue

Armin Heinlein1
Giga Expert

I have a workflow (CSM Training Request) that should wait for an external Event to be triggered. The event name is "state.resolved.changed" and is fired by a Business Rule. 

gs.eventQueue('state.resolved.changed', current, gs.getUserID(), gs.getUserName());

The event log shows that the event is fired but the workflow is still waiting for the event. 

What am I doing wrong?

 

I solved it! I had to use the script below in the Business Rule

var wf = new Workflow().getRunningFlows(current);

while(wf.next()) {

newWorkflow().broadcastEvent(wf.sys_id, 'state.resolved.changed');

}

1 REPLY 1

Harshinya1
Mega Guru

"Wait for WF Event" Workflow Activity will work only when event is fired within workflow. Refer to below notes.

 

 

The Wait for WF Event activity causes the workflow to wait at this activity until the specified event is fired from another activity in the workflow. Events from other activities are fired in a script using the workflow.fireEvent('eventName') API call.

https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/workflow-activities/reference/r_WaitForWFEvent.html

 

Refer to below documentation

https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/workflow-administration/reference/r_WorkflowEventSpecificFunctions.html