cancel
Showing results for 
Search instead for 
Did you mean: 

start a processInstance with a certain user

pamasoft
Champ in-the-making
Champ in-the-making
I want to start a process instance with the Java API method 'startProcessInstanceById(String processDefinitionId)'in the RuntimeService interface and I want  the 'starter' to be set to a certain userId.
Just calling the method directly gives the 'starter' user set to 'anonymous'.

Any ideas?

I am using Activiti - Engine 5.14 API
(Java 1.7, Ubuntu 12.04)
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

you can set authenticated user.

  private String startProcessAsUser(String processId, String userId) {
    try {
      identityService.setAuthenticatedUserId(userId);
      return runtimeService.startProcessInstanceByKey(processId).getId();
    }
    finally {
      identityService.setAuthenticatedUserId(null);
    }
  }

Regards
Martin