A question about multiple threads with escalation rule

  • 3 April 2014
  • 9 replies
  • 2 views

Badge

Hi, 

 

I currently design a workflow having two threads with escalation rule. The picture attached/below shows my workflow.

15864i65F78FB9E064A664.png

 

When starting an instance, one thread is on Complete Client File and another is on Full payment Receive. In first thread, there is an escalation rule that if we proceed more that 21 days in both Signed Documents Received activity and Asia Document Approval activity, we will be moved to Doc Approval activity. If it gets cancelled there, it goes to Email cancellation which is an end point of workflow. 

I wonder at this moment, what happen for another thread on Full payment Receive activity?? If one thread moves to the end, how can I implement to kill another as well? If on Asia Document Approval more than 21 days, also got approval in Doc Approval, how can it move back to Asia Document Approval directly?? 

Also I checked K2ServerLog database and found there is only one process instance for it. Anyone can explain a little more will be so appreciated. 


13949i8E4E9A0FB4994257.png

9 replies

Badge +3

As there are two (parallel) threads in your workflow, if the first thread completes and goes to the end point of the workflow, the workflow has not yet completed because the second thread is still active. That is why you see that there is a single process instance.

 

There is a action you can execute in the workflow known as 'GotoActivity'. The action has an input parameter that is the named of the activity in the workflow to jump to. Effectively it forces the workflow to move to a particular activity regardless whether there are multiple threads.

 

Badge +3

Thank you Kenny for your reply. I somehow assume what you describe is how it works but I have more concern about how to kill the other active when one is inactive. 

Thanks.


@KennyC wrote:

As there are two (parallel) threads in your workflow, if the first thread completes and goes to the end point of the workflow, the workflow has not yet completed because the second thread is still active. That is why you see that there is a single process instance.

 

There is a action you can execute in the workflow known as 'GotoActivity'. The action has an input parameter that is the named of the activity in the workflow to jump to. Effectively it forces the workflow to move to a particular activity regardless whether there are multiple threads.

 


Badge +8

The GoToActivity() expires all other activities currently running.  So when you use it, everything that is active is gone.

 

There is an overload for the GoToActivity() method that allows you to not expire all other activities, but it must be called from a Server Code event.

Badge +3

@sbrownhuntoilco wrote:

The GoToActivity() expires all other activities currently running.  So when you use it, everything that is active is gone.

 

There is an overload for the GoToActivity() method that allows you to not expire all other activities, but it must be called from a Server Code event.


Thank you for your reply. 

Do you mean using GoToActivity() on Thread A will automatically eliminate the other parellel thread(s)??

I will definitely try. But I want those threads back to their activities after they gets approved. In that case, how can I do it then??

:(

Badge +8

Then I misunderstand what you have posted.  The GoToActivity() method will expire all other activities when it runs (unless you use the overload telling it not to do so).

 

It sounded like you wanted the other threads to stop when the escalation hits.  But now you are saying otherwise.  Could you clarify your requirements?

 

EDIT


OK, I re-read and I think I understand what you want.  Add an activity on your Declined Doc Approval line.  That activity contains a Server Code Event.  View the code for this event and add the following:

K2.GoToActivity("Email Cancellation");

 This code will only ever be executed if the outcome from the Doc Approval activity is Declined.  If and only if the approval is declined will this code run that expires all activities currently running in the workflow.

Badge +3

Another thing I thought you misunderstand is that I saw only one process instance in database but two threads is showing in the picture below. Not like what you said.

 

16784i98F135FCD70E6F26.png

 


@KennyC wrote:

As there are two (parallel) threads in your workflow, if the first thread completes and goes to the end point of the workflow, the workflow has not yet completed because the second thread is still active. That is why you see that there is a single process instance.

 

There is a action you can execute in the workflow known as 'GotoActivity'. The action has an input parameter that is the named of the activity in the workflow to jump to. Effectively it forces the workflow to move to a particular activity regardless whether there are multiple threads.

 




Badge +3

K. My requirements are:

 

1. When thread A goes to Doc Approval after 21 days and get declined and then cancelled, the process instance (including thread A and thread B which is active on Payment Received I suppose) will be expired.

 

2. When thread A goes to Doc Approval after 21 days and get approved, A should gets back to where it was (should be from either Doc Received or Asia Doc Approval activities). 

 

3. 21 days means the maximun time spending between Doc received activity and Asia Doc Approval activity. 

 


@sbrownhuntoilco wrote:

Then I misunderstand what you have posted.  The GoToActivity() method will expire all other activities when it runs (unless you use the overload telling it not to do so).

 

It sounded like you wanted the other threads to stop when the escalation hits.  But now you are saying otherwise.  Could you clarify your requirements?

 

EDIT


OK, I re-read and I think I understand what you want.  Add an activity on your Declined Doc Approval line.  That activity contains a Server Code Event.  View the code for this event and add the following:

K2.GoToActivity("Email Cancellation");

 This code will only ever be executed if the outcome from the Doc Approval activity is Declined.  If and only if the approval is declined will this code run that expires all activities currently running in the workflow.




Badge +8

(1) is accomplished by my edit above: Add an activity with a Server Code event on your Declined line.

 

(2) is just a matter of routing correctly when the approve action is taken.

 

(3) is a matter of timing your escalations correctly.

 

Try it.  It will work.

Badge +3

I know it gotta be myself to solve my question as solved all previous 5 questions.

After I read the thread below and tested, indeed GoToActivity will merge all threads into one.

 

http://community.k2.com/t5/K2-blackpearl/Best-Way-to-run-a-parallel-Process/td-p/53967

Reply