WAIT for workflow Event Issue

Kiran Patil3
Giga Expert

Hi,

I have two catalog Item (Workflow:1 & Wokrflow:2) in order Guide. As soon as Order request is submitted, two RITM are created underneath REQ.

As per my requirement, Workflow:2 should wait till particular task is closed in Workflow:1

As per docs, I have added WAIT for WF Event and also script to generate Event but still failing.

 

#Workflow:1

find_real_file.png

//Generating Event in RUN SCRIPT Activity

var w = new Workflow(); 
w.fireEvent(current, 'Execute.Workflow.2');

#Workflow:2

find_real_file.png

 

 

#WAIT for WF Event Activity

Event is also registered in Event Registry table.

 

find_real_file.png

Issue: Workflow:2 never moves from WAIT for WF Activity.

Personal Instance: New York

Does, anyone have faced the issue.

 

 

 

1 ACCEPTED SOLUTION

Manish Vinayak1
Tera Guru

Hi Kiran,

Fire event triggers the workflow event to the workflow context from current record, however I think you want to trigger the event from one RITM's workflow context to another RITM's workflow context. You need to get the running context from RITM 2 in order to trigger the event to that workflow.

You need to query RITM table to find out the RITM record to which the other workflow is associated.

Try the following code:

var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", current.request);
ritm.addQuery("sys_id", "!=", current.sys_id);
ritm.query();
while(ritm.next()) {

  var wf = new Workflow().getRunningFlows(ritm);
      while(wf.next()) {     
          new Workflow().broadcastEvent(wf.sys_id, 'Execute.Workflow.2');
      }
}

 

Give it a try. Hope this helps!

Cheers,

Manish

View solution in original post

5 REPLIES 5

Hi Vishal,

I think, sub-workflow wont fit the scenario here. Example was just for demo but actual workflow has 430/40 task in each and they are inter-dependent and also we cannot have just one catalog item, it has to be order-guide for some other reasons.

 

Thank You