cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti tasks as web flow in a webapp

antonylees
Champ in-the-making
Champ in-the-making
Hi all

I'm thinking of using Activiti as a webflow/workflow engine for a webapp I'm designing.  I can implement it so that the first request sets off the process but at some point a task will need user input in order to proceed.  The engine would then need to decide on the next task based on the input from the user (via a web request)

I had thought that I could maybe simulate a user, with the username as the request ID, but if I store the execution ID so it can be retrieved on the next web request, is there a way of kicking the process off from the task that was last completed?

Antony
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
Hi,

If a process is waiting in a user-task, you can just complete the task, which 'signals' the execution to move further. You can pass the variables you collected from the user too, so you can eg. make gatewa decisions based on what the user put in.

API:
taskService.completeTask(taskId);
taskService.completeTask(taskId, variables);

antonylees
Champ in-the-making
Champ in-the-making
Sounds ideal!
Many thanks  Smiley Happy
Antony

antonylees
Champ in-the-making
Champ in-the-making
I've just been trying this out - so I have a user task, that I can complete programmatically, works really well thanks  Smiley Happy

If the following part of the flow is an exclusive gateway, which depends on the user's input, is the way to do this to create a service task between the user task and the gateway to extract the variables?  Or is there a better way?

antonylees
Champ in-the-making
Champ in-the-making
Actually, ignore that one, I answered my own question I think - the variables get passed through the flow from one task to another?

frederikherema1
Star Contributor
Star Contributor
The variables that are passed when the task is completed, are stored on the process-instance. The next task in that process will have access to it, indeed.

antonylees
Champ in-the-making
Champ in-the-making
Brilliant, thanks  Smiley Happy