Modify process instance name

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member II

Modify process instance name

Jump to solution

Dear community.

Is there a way to modify the name of a process instance?

I'd prefer to use an execution (or task) listener for this purpose. Having ${processInfoBean.getProcessName(execution)} to get the process instance name I wonder whether there is a method to modify the process instance name.

Best regards

Marco

1 Solution

Accepted Solutions
Senior Member

Re: Modify process instance name

Jump to solution

> Is there a way to modify the name of a process instance?

You can user public api 'RuntimeService.setProcessInstanceName(String processInstanceId, String name)'.

RuntimeService (Activiti - Engine 5.22.0 API) 

* Java example

execution.getEngineServices().getRuntimeService().setProcessInstanceName(execution.getProcessInstanceId(), %NAME%);

* Expression example

${execution.getEngineServices().getRuntimeService().setProcessInstanceName(execution.getProcessInstanceId() , %NAME%)}

View solution in original post

12 Replies
Senior Member

Re: Modify process instance name

Jump to solution

> Is there a way to modify the name of a process instance?

You can user public api 'RuntimeService.setProcessInstanceName(String processInstanceId, String name)'.

RuntimeService (Activiti - Engine 5.22.0 API) 

* Java example

execution.getEngineServices().getRuntimeService().setProcessInstanceName(execution.getProcessInstanceId(), %NAME%);

* Expression example

${execution.getEngineServices().getRuntimeService().setProcessInstanceName(execution.getProcessInstanceId() , %NAME%)}

View solution in original post

Active Member II

Re: Modify process instance name

Jump to solution

Thank you daisuke-yoshimoto!

Your reply was very helpful!

Since it didn't seem to work for me I imported your process and it didn't work either.

What I found so far is, that modifications of the process intance name doesn't work before end of the first user task. So for the first user task it does not work with the Start event of the Execution Listener or the Create event of the Task Listener. But it does work with the End event of the Execution Listener and the Complete event of the Task Listener. For the second user Task it does work with the Start event of the Execution Listener and the Create event of the Task Listener. Using a Service Task (or Script Task) between Start and the first user task doesn't help as well. The process name cannot be modified before the end of the first user task.

We run Alfresco Process Services 1.6.0.

Best regards

Marco

Senior Member

Re: Modify process instance name

Jump to solution

When do you want to change process instance name?

Active Member II

Re: Modify process instance name

Jump to solution

The best would be using an Execution listener of the Sequence flow just before the first user task. Doing so I'd be able to modify the process instance name before the first user gets involved.

Senior Member

Re: Modify process instance name

Jump to solution

> The best would be using an Execution listener of the Sequence flow just before the first user task.
> Doing so I'd be able to modify the process instance name before the first user gets involved.

Thank you for your reply.
I made the sample for your use case.

Active Member II

Re: Modify process instance name

Jump to solution

Mmmhhh, as I wrote: this doesn't work. In my system modifications of the process name don't work before the end of the first user task.

Does it work for you?

Senior Member

Re: Modify process instance name

Jump to solution

I'm sorry, I didn't checked it in the same environment as you.
I checked it with Activiti engine 5.21.0.

Now, I checked it in the same environment as you(Alfresco Process Services 1.6.1) and got error as follows.

org.activiti.engine.ActivitiException: Unknown method used in expression: ${execution.getEngineServices().getRuntimeService().setProcessInstanceName(execution.getProcessInstanceId() , 'mod_name')}] with root cause
org.activiti.engine.impl.javax.el.MethodNotFoundException: Cannot find method 'getEngineServices' in 'class
‍‍

Probably, it seems that Alfresco Process Services limit EL expression, unlike Activiti Engine.
You can use modify process instance name by using an Execution listener(directly java program).

I made sample code and uploaded.

Active Member II

Re: Modify process instance name

Jump to solution

ah ok .. understood.

I was hoping that I could stay on the modelling site of the game but anyhow: thank you very much for the effort .. your help is most appreciated!

Active Member

Re: Modify process instance name

Jump to solution

i tried setting the process instance name in the first user task listener, but it doesnt change the title, i have tried keeping this listener at multiple places but it seems to not change the header in the web.

has anyone tried and got results