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
Solved! Go 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%)}
> 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%)}
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
When do you want to change process instance name?
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.
> 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.
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?
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.
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!
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
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.