String processInstanceId = taskInstance.getProcessInstanceId();
ProcessDefinitionManager processDefinitionManager = Context.getCommandContext().getProcessDefinitionManager();
ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);
if(processInstanceImpl.hasEnded()){
return false;