Setting caseInstanceId in a newly created processInstance

Hi ,

I am restarting a completed process instance using below snippet:

private void restartFailedProcessInstances() {
		List<HistoricIncident> failedJobs = processEngine.getHistoryService().createHistoricIncidentQuery().incidentType("Failed Job").list();
		if(failedJobs != null) {
			for(HistoricIncident incident : failedJobs) {
				logger.info("restarting process instance id {} " ,incident.getProcessInstanceId());
				runtimeService.restartProcessInstances(incident.getProcessDefinitionId()).processInstanceIds(incident.getProcessInstanceId()).startBeforeActivity(incident.getActivityId()).execute();
				logger.info("restarted process instance id {} " , incident.getProcessInstanceId());
				processEngine.getHistoryService().deleteHistoricProcessInstance(incident.getProcessInstanceId());
			}
		}
	}

But, the case instance id (in execution table) is not getting set as it was in the completed case.
I want to know if there is a way to set it after the process instance is recreated.

Thanks
Urvashi

1 Like

Hi Urvashi,

I’m afraid that is currently not possible. But feel free to create a feature request in our JIRA tracker and, if you like, submit a code contribution. For example, the RestartProcessInstanceBuilder could have an option withCaseInstanceId so that users can choose if they want the case instance id taken over or not.

Cheers,
Thorben