Workflow Broadcast Event not working....

DChandlerKy
Tera Guru

I have a workflow that has a subflow that validates that all tasks associated with the parent RITM are indeed in a complete state before allowing the primary workflow to complete the RITM. (We have a valid use case in some catalog items where the teams may/may not create additional/manual catalog tasks.) v1 of the task validation subflow had a timer and a rollback activity and I failed to realize there was a max activity count which caused that subflow and parent workflow to complete even though there were active tasks on that ritm.
For v2 - I am now trying to use an event. I updated the subflow with the “Wait for WF Event” activity. Created a new event which is identified in that workflow activity. Created a business rule which runs perfectly - except it is not firing/broadcasting the event. I then moved most of the logic in the BR to a script include, and I am still unable to get the event to be broadcast out. (Ie: I don’t see it in the event logs and the workflow does not proceed.) Everything else in the script works - except the event being broadcast.
I did verify in the BR that the sys_id of the RITM is the correct sys_id and that is what is being passed into the script include below as "ritmID". So far my tests have been with RITMs that have no active tasks to make sure the event is fired. Note that when this runs - there will be TWO active workflows on the parent RITM - 1) primary workflow, 2) task validation workflow

Task Validation Script Include Code: 

activeTaskCheck: function(ritmID) {
        //Triggered by “UKHC Task Validation” BR on Catalog Task table
        //This will query the ritm record to see if there are any catalog tasks that are open/active on that ritm.
        //If no active tasks are found, this script will trigger an event so the Task Validation (subflow) workflow may proceed.
        //Query to identify all catalog tasks associated with the same parent that are still active
		gs.log(“UKHC Task Validation - activeTaskCheck now running.“);  //I do see this in the logs
        var grTask = new GlideRecord(‘sc_task’);
        grTask.addQuery(‘request_item’, ritmID);
        grTask.addQuery(‘active’, true);
        grTask.query();
        if (grTask.hasNext()) {
            //if there are active catalog tasks found.... nothing to do
            gs.log(“UKHC Task Validation: Active Task found for ” + grTask.requsted_item.getDisplayValue());
        } else {
            //if there are no active catalog tasks found...
            //trigger event
            //gs.eventQueue(‘task.validation’, ritmID); //this does fire the event, but the workflow doesn’t advance
	    gs.log(“UKHC Task Validation: Not active task found”); //I do see this in the logs
            var wf = new Workflow().getRunningFlows(ritmID);
            while (wf.next()) {
                //new Workflow().broadcastEvent(wf.sys_id, “task.validation”);  //tried wf.sys_id and just wf and did not work. also tried single vs double quotes
		new Workflow().broadcastEventToCurrentsContexts(wf, “task.validation”); //got idea to try this while looking at options inside the Workflow script include. Tried with both wf.sys_id and just wf, and both single/double quotes
            }
        }
    },

 

Other than the Event Logs - where can I see if the event did trigger or not? 
Any ideas why this is not broadcasting the event? We are currently on Rome and testing for an upgrade to Tokyo while I am trying to fix this. 

3 REPLIES 3

-O-
Kilo Patron
Kilo Patron

Can you share how is the subflow started?

The subflow (Task Validation) is started from within the parent/primary workflow. 

Francisco11
Tera Contributor

Hi,

We have a similar problem with this event launcher. We have a workflow at REQ level that is waiting for an event triggered from the different RITMs it contains but this trigger is not being received by the REQ that is waiting for it, we use it:

new Workflow().broadcastEvent(wf.sys_id, event);

Our release is Utah.

Any solution?

Thanks.