Process Instance Creation will be done by which User?

I want to Create a process Instance through Java API. I use the Below Code:

ProcessInstance processInstance = processEngine.getRuntimeService()
.startProcessInstanceByKey(“SampleBPMNProcess”);

So if i create the Process Instance by using the above Line the instance is created. But is it not possible that we create a Instance with an user, So that we can easily filter the Process Instance created by a corresponding User. Is there some other possible approach

Thanks,
Jayapragadeesh J

Hi @Jayapragadeesh,

you just have to add

identityService.setAuthenticatedUserId("userIdForJonny");

before the process instance start.

See the JavaDoc for further details: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.14/org/camunda/bpm/engine/IdentityService.html#setAuthenticatedUserId-java.lang.String-

Hope this helps, Ingo

Where can we retrieve the information about what user created the process? ProcessInstance does not seem to hold it. Where is the information used?

Hi @fml2,

you can access the ID through the history API, e.g.: https://docs.camunda.org/manual/7.14/reference/rest/history/process-instance/get-process-instance/#result.

Hope this helps, Ingo