What do you mean by rejecting, can you be more specific ? You can go through the API documentation for org.kie.api.task.TaskService and see which methods you can use.Along with that you can go through the task life cycle diagram(see attachment). I believe you might need fail/exit methods and for that you need to have taskId and userId. Following is the code fragment to get the TaskService object
RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId)); //In case if you are using session per process instance strategy.Where processInstanceId is the id //associated to process for this task and runtimeManager depends on how you configure jBPM in your environment.
TaskService localTaskService = engine.getTaskService();
HTLifeCycle.PNG 82.2 KB
Thanks for you soon respond.
I actually need a method to revoke the current task to previous state. The fail method does that? Or there is another method to do it?
I dont think so you can goto previous state in human task as per the task life cycle. But I will leave it to experts to provide advice.
Hmmm... But How can I revoke a task? what would be the method from taskService?
mmm what do you mean by go back to a previous state? could you please give an example of what you are trying to achieve?
You can release a task that is assigned to someone, which will go back to reserved state (this is the human task life cycle http://dcalca.files.wordpress.com/2011/05/screenshot-11.png?w=645&h=438). But I am not sure what you are trying to achieve..
I wan to achieve the following, for example:
1. Task A assigneed to Carlos with status "Ready". When Carlos completes it, this task automatically is assigneed to the following actor (Mary)
2. Now Task B assigneed to Mary with status "Ready", in this case I want to return or revoke or reject this task to Carlos again, due to the task does not accomplish with some criterials.
3. When Carlos logs in, its task list will show the task again with status Ready, which was completed before.
I think this will be useful..
1. first you need to add "Database Exclusive Gateway" in between start node and Task A.
2. Then you need to again add "Database Exclusive Gateway" in between Task B and End node.
3. The gateway which connect to end node should be connect to first gateway which is connected to Task A.
4. All gateways should have three directions connectivities.
5. The add following scripts to the second gateways if it is completed then go to end ("return KieFunctions.isTrue(TaskA.getApproval())==true;") (please note that this is an example and you have to create TaskA and .Approval in the data modeler.
6. if it is rejected then add this script to the directions of the second gateway which is connected to first gateway ("return KieFunctions.isTrue(TaskA.getApproval())==false;")
Thanks so much
I will try this.. that makes sense for me
But keep in mind if the out come of task B is negative(in your case rejecting) it will complete the instance of Task B and will create a new instance of Task A in DB. You can not change the state of Task B instance nor Task A instance to previous state. Hope you understood that.
I have the following issue when I complete a user task. The flow should get to conditional gateway as the picture below.
But the problem is no matter what values the variables values into the condition, The flow always goes to sequence named "Rejected".
Please someone has any idea which will be the problem
Thanks in advance.