cancel
Showing results for 
Search instead for 
Did you mean: 

how to create user task programmatically

rohran
Champ in-the-making
Champ in-the-making
How do we create a user task programmatically and assign to the existing process instance provided that I know the proc_inst_id_, task_def_key & task_name_ ?

In my use case, I need to create user task to the existing process instance only if certain condition is met.

-rohran
6 REPLIES 6

trademak
Star Contributor
Star Contributor
Hi,

Via the TaskService. You can use the newTask and saveTask methods.

Best regards,

hamed
Champ in-the-making
Champ in-the-making
Hi,

Via the TaskService. You can use the newTask and saveTask methods.

Best regards,

Hi,

There are no setter methods for processInstanceId or similar things,How we can attach newly created Task to processInstance ?!

meyerd
Champ on-the-rise
Champ on-the-rise
This is not possible using public API. You would have to write a custom command. Have a look at the database tables first in order to understand how tasks and executions are linked.

hamed
Champ in-the-making
Champ in-the-making
Thanks for your fast reply
I'v understood what you said, but I want to know that is this a bad approach to do that ?

meyerd
Champ on-the-rise
Champ on-the-rise
Hi hamed,

well, it depends. If you use internal API you might get burned if we change something internally. Public API is guaranteed to be stable.

I would always try very hard resolving something like this using the process diagram. Is there no way to model it in the process?

hamed
Champ in-the-making
Champ in-the-making
Actually, I agree with you, but always there are issues that appear after processDefinition design and use(processInstance)!
e.g We need some feature that could be returned the running node to previous node(task), to do some editing or things like that. So, if I put all possibilities in diagram it would be a problem and complexity (I guess)