08-03-2018 09:57 AM
I have a Process Definition that makes a number of different calls to a subprocess via Call Activity, as the subprocess is called multiple times for many different reasons, I'd like to be able to set the 'Name' for each instance of the called subprocess, so that name gets displayed on the Admin Console - see screen shot
I tried setting a Java Listener to modify the name e.g. and setting it as a start event in the subprocess, but that does not seem to take any effect. I also tried a script based listener doing similar, but again the name does not seem to get set.
We are using Alfresco Activiti Enterprise BPM Suite v1.5.0
public class ModProcessInstanceNameListener implements ExecutionListener{
private static final long serialVersionUID = 3381970945383360304L;
@Override
public void notify(DelegateExecution execution) throws Exception {
execution.getEngineServices().
getRuntimeService().
setProcessInstanceName(execution.getProcessInstanceId(), "myname");
}
}
08-06-2018 02:50 AM
Hi,
You can chek this test case where you can change the current process instance name in activiti 6. You can check the for the same test case exists in the 1.5 as well....
Activiti/RuntimeServiceTest.java at 6.x · Activiti/Activiti · GitHub
Test this method :testSetProcessInstanceName
08-06-2018 11:57 AM
Where did you use the ExecutionListener?
08-06-2018 12:33 PM
Thanks for the suggestions and question. I tried running that Unit Test that sets the process instance name using Version 1.5 and yes it works.
Regarding where I put the listener, I tried it on the Start of the Process, with the listener listening to the 'start' event type. I also tried it on the first transition arrow, after the 'start'.
However today rather than setting on the listener, I realised the Called Process always makes a call to a JavaDelegate's execute(DelegateExecution execution)
so today I tried setting the process name in there to a process variable.
@Override
public void execute(DelegateExecution execution) throws Exception {
String currentActivityId = execution.getCurrentActivityId();
logger.debug(String.format( "CurrentActivityId: %s , for processInstanceId:%s", currentActivityId, execution.getProcessInstanceId() ));
if (currentActivityId != null && currentActivityId.equals("restRetryTask")) {
RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
String taskName = (String) execution.getVariable("taskName");
logger.debug(String.format("Setting ProcessInstanceName to TaskName: %s , for processInstanceId:%s", taskName, execution.getProcessInstanceId()));
if (taskName != null) {
runtimeService.setProcessInstanceName(execution.getProcessInstanceId(), taskName);
}
}
And interestingly, this seems to correctly set the value into the ACT_HI_PROCINST table for the called process, I can run a SQL query to check (see screenshot below). However the value still does not appear in the Admin App UI
SELECT * FROM act_hi_procinst WHERE PROC_INST_ID_ = 5522689
Admin UI for parent process
Admin UI for Called Process
Any thoughts gratefully received.
08-07-2018 05:53 AM
It works fine on 1.9 could be an issue with the admin app UI that was fixed post to 1.5.
Does the REST API return the process instance name?
POST
http://hostort/activiti-app/api/query/historic-process-instances?tenant_id=1
{
"superProcessInstanceId": "40010"
}
Note replace tenant_id with the tenant you are using.
Explore our Alfresco products with the links below. Use labels to filter content by product module.