cancel
Showing results for 
Search instead for 
Did you mean: 

start process instance by user

seba1
Champ in-the-making
Champ in-the-making
Hello,

I would like to start a new instance of a process from a java application.
Actually I find this:
 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");
But I would like to see the process status on Activiti Explorer with the admin user (kermit).
How I can assign a user or user group in my process intance ?

tanks for help.
16 REPLIES 16

jayehsea
Champ in-the-making
Champ in-the-making
I have the same question. How do I assign an owner to a started process? Or when I start a process? I have found that the processes I have started via a web application do not show up in My Instances in Activiti Explorer. However, the same process started via Activiti Explorer are displayed in My Instances.

By looking into the database I found that ACT_HI_PROCINST table has a column 'start_user_id_'. This column contains the user ID of the user that started the process using Explorer. However, processes started using runtimeService.startProcessInstanceByKey( processDefinitionKey, variables) do not have any value in 'start_user_id_'. This is why the running process do not display in My Instances.

In my database, I used SQL to change the 'start_user_id_' to the appropriate user ID. Now the processes display in My Instances.

How can accomplish this from code? I have read through a good portion of the API and have not found a solution.

Thanks!!

rogerofyan
Champ in-the-making
Champ in-the-making
I think what you means is called 'initiator', who start the process instance.
This is a activiti extention on start node, you can specify a initiator property, that identifies the variable name in which the authenticated user id will be stored when the process is started. Example:
<startEvent id="request" activiti:initiator="initiator" />The authenticated user must be set with the method BEFORE the process instance is started,
try {
  identityService.setAuthenticatedUserId("bono");
  runtimeService.startProcessInstanceByKey("someProcessKey");
} finally {
  identityService.setAuthenticatedUserId(null);
}
Then, you can refer the initiator(you can treat it as process owner) variable in the rest of process definiton:
<userTask id="examine" name="examinePaper" activiti:assignee="${identity.findLeader(initiator)}">
</userTask>

you can find more information about this in the User Guide Chapter 8. BPMN 20 Constructs  "start event'.

jayehsea
Champ in-the-making
Champ in-the-making
Thank you very much. The information in your reply provided exactly what I needed. Thanks for the help!!

seba1
Champ in-the-making
Champ in-the-making
yes same form me ! Thanks you very much

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
I think this should make a nice addition to the documentation. Or a faq…

chaoyy
Champ in-the-making
Champ in-the-making
Solve my question also, Thank you!

jbarrez
Star Contributor
Star Contributor

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Ooops… Clearly have not been in the docs for a while…

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
But it shows how lazy new users are. I see this here and in primefaces forum also…