cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best way to design a process which allows user to recall back to his task.

chenning007
Champ on-the-rise
Champ on-the-rise
Hi folks,

I am not sure this is the proper place to raise this question, if not please kindly let me know.

My question: is it possible for activiti engine to allow user to recall back to his task, for example

start -> task A -> task B -> task C -> end

if task A is completed by user A, process goes to task B and waits for user B's completeness, however, before user B performs to complete task B, user A would like to recall the task from task B back to A and complete the task A again with more information. Is there any good way to design the process and achieve the requirement, please advice, thank you.

Best Regards!

– Ning
25 REPLIES 25

tloomba
Champ in-the-making
Champ in-the-making
Hi Martin,

thank you very much for providing an example of creating and implementing a custom command. This worked well to the extent that the custom command does get executed without any errors. I tried the example you provided above, which is set the activity id of the current execution to the desired activity where we'd like to re-route the execution too. The execution however just sits at that activity without moving downstream. Is there a new job that needs to be created after setting the activity id? My main goal is to set the new activity id but also have the execution route to that activity and move downstream from there. Would you please tell us know how to do that?

Thank you very much for your help!

Tavishi Loomba

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Tavish,

The execution however just sits at that activity without moving downstream.

In the case when you wan to run the execution, you have to signal it.
e.g.:

getCommandExecutor().execute(new SignalCmd(executionId, signalName, null,
                null));

Regards
Martin

tloomba
Champ in-the-making
Champ in-the-making
Hi Martin,

thank you again! What should be the value of the signalName parameter in the constructor call for SignalCmd? We tried null as signalName and also "compensationDone" which we found in various forum posts, but neither worked.

Also, will sending the Signal to the execution be enough to run the execution further, or are there additional commands we should invoke? I regret having to keep coming back to you for additional questions. There is no javadoc on classes such as SignalCmd, Command classes. We have spent lot of time searching Activiti forums and the web, but are not finding any concrete examples or documentation. Does documentation exist for how such design patterns (for example custom Command) should be implemented?

We are using Activiti version 5.19.

Thanks!
Tavishi

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Tavishi,

The best would be to create jUnit test as an example. When I will have a time I can create one. (Or you can help me too -> just prepare what you have to the jUnit test template https://forums.activiti.org/content/sticky-how-write-unit-test and I can add what is missing.)

Regards
Martin

tloomba
Champ in-the-making
Champ in-the-making
Thank you! Yes, I will prepare one and have it available by tomorrow. Does it matter that our project uses Sping Data JPA version 1.8 and Hibernate JPA version 2.0 with Activiti version 5.19? Can my unit test only include the H2 db configuration, or will it make a difference to the design implementation?

Also, how do I submit the unit test to you?

jbarrez
Star Contributor
Star Contributor
As long as we can run it easily, that's the main goal. H2 is preferred, yes.

> Also, how do I submit the unit test to you?

Github repo is the easiest

evavilaginés
Champ in-the-making
Champ in-the-making

Hi,
I'm very interested in this post because just I have to implement the "reverse" in a flow of activiti (to allow user to recall back to his task and forward).

Is there any available example of the solution described here? Or another better solution?

I have tried to implement the solution described here but not get it to work (I'm new programming in activiti) .

Any help is welcome.

Thank you very much,



martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

you can wait on Tavishi's jUnit test our you can create your own, and we can work on the example together.
https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

tloomba
Champ in-the-making
Champ in-the-making
Martin and Joram,

Thank you very much for your responses. I will creating and posting the Junit test in a couple of weeks. I really appreciate your input and help.

Thanks!
Tavishi

tloomba
Champ in-the-making
Champ in-the-making
Hi Martin,

I created the unit test in the maven project template your team provides. Please download "SendToActivitiUnitTest.zip" from https://github.com/tloomba/SendToTestTavishi. As a recap, following is the use case I am trying to achieve:

Re-route a process instance from a downstream step where it is stopped at a wait state to a previous upstream step, and have the execution move downstream based on the transition conditions, as it normally would the first time it entered the upstream step. In the attached project I created a sample process called TestSendTo.bpmn. In this process the first wait state the execution could stop at is User Task 1. When the execution moves downstream it could stop at User Task 2, and further downstream it will always stop at Receive Task. Following are the types of re-routing use cases I would like to achieve:

1) When the process has moved downstream and stopped at Receive Task, re-route it to Service Task 1. The execution should move downstream from Service Task 1 as it normally would, based on the transition conditions.

2) If the process has moved downstream and stopped at User Task 2, re-route it to Service Task 1. The execution should move downstream from Service Task 1 as it normally would, based on the transition conditions.

3) If the process has moved downstream and stopped at User Task 2, re-route to User Task 1. The execution should move downstream from User Task 1 once it is completed, as it normally would, based on the transition conditions.

Just to clarify again, our goal is to achieve above use cases without drawing transitions in the process model. I added a unit test in MyUnitTest.java which attempts use case #1. As you see I created a custom command with the code you provided above on May 31st. I invoked the custom command to achieve the re-routing from Receive Task to Service Task 1, and then signaled the command as you suggested above using the line:

"commandExecutor.execute(new SignalCmd(task.getExecutionId(), "compensationDone", null, null))"

The process instance should now have moved to User Task 1 since the variable 'goToUserTask' was set to true. However, if you execute the unit test you will notice at line 68 when we retrieve the process instance again, it seems to have stopped at Service Task 1 and does not move downstream. We did not know what should be the value of the "signalName" parameter for SignalCmd constructor. Our project is depending on the satisfaction of these use cases for the success of the project, and we also are nearing our deadline in a few weeks. I'd have immense gratitude if you are able to review this and get back to me at your earliest convenience!

Thanks,
Tavishi