How to add an initiator when the process starts

I have no way to set the START_USER_ID_ field in the ACT_HI_PROCINST table when the process starts, how can I set it?

Looking forward to your help.Thtanks

wisdom

And now I use identityService.setAuthenticatedUserId(user) befor start process,but failed to start.

Help me.Thanks

wisdom

Hello @wisdom ,

for this, the start event has an initiator field. It will cause the user id of the currently active user to be saved in the given variable name.

Jonathan

Thank you for your answer.
Sorry, I didn’t quite understand what you meant. Set the field of the initiator at startup, but I see that this setting is not provided in the startup method.

wisdom

Hello @wisdom ,

the field can be set in the diagram using Camunda Modeler.

If you then start the process programmatically, you need to set the currently authenticated user in the Authorization service of the process engine API.

Jonathan

Yes, I have this setup in a spring boot project. Now I use “identityService.setAuthenticatedUserId(userId)” to set it up, but I get an error when starting the process.

wisdom

1 Like

Hello @wisdom ,

great you found the correct place in the API.

What is the error?

This is the problem on my side, but this definitionKey exists

wisdom

Hello @wisdom ,

do you have authorization enabled?

Jonathan

How to perform resource authorization if an instance has not been generated before the process is started?

wisdom

Hello @wisdom ,

process definitions have an authorization called CREATE_INSTANCE.

Also, a process instance has the authorization CREATE.

Jonathan

Can you give me an example, I haven’t delved into the authorization function, I have tried to set it up just now, but there is a problem with setting the authorization.

wisdom

Hello @wisdom ,

to be able to ignore this, you can disable authorization via application.yaml

hello,
I have disabled authorization in yaml.Now how do I handle this?

So authorization is not a problem anymore.

But still, the process definion is not found?

Can you insert a query that lists all available process definitions before?

Yes,this process definitionKey exists.And If I don’t add identityService.setAuthenticatedUserId(userId) the program is running normally.

Ok. I have to admit that I am running out of ideas…

@Niall @Ingo_Richtsmeier do you have an idea?

Thanks for your answer, I’ll think of another way.

wisdom