Hello ,
Is there a way we can identify a local variable from the ACT_HI_VARINST or to put it in a differently is there a way to differentiate process variables vs local variables .
Version :- Camunda 7.13.0 Community Edition
Thanks
Dinesh
@dineshsb , ACT_HI_VARINST table contains both process variables and local variables.
I was setting below local variable in one of the user task. So here the scope of the local variables is to that task level.
delegateTask.setVariableLocal("notifyTaskListener", true);
Local variables will be persisted in ACT_HI_VARINST and can be identified with taskId. If taskId is present then the variables is local variable . If taskId is not present for that variable, then it’s a process variable.
Refer the below variables which has taskId for the local variables.
Execution flow of local variables create/update/remove:
}
}
protected void invokeVariableLifecycleListenersCreate(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope) {
invokeVariableLifecycleListenersCreate(variableInstance, sourceScope, getVariableInstanceLifecycleListeners());
}
protected void invokeVariableLifecycleListenersCreate(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope,
List<VariableInstanceLifecycleListener<CoreVariableInstance>> lifecycleListeners) {
for (VariableInstanceLifecycleListener<CoreVariableInstance> lifecycleListener : lifecycleListeners) {
lifecycleListener.onCreate(variableInstance, sourceScope);
}
}
protected void invokeVariableLifecycleListenersDelete(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope) {
invokeVariableLifecycleListenersDelete(variableInstance, sourceScope, getVariableInstanceLifecycleListeners());
}
protected void invokeVariableLifecycleListenersDelete(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope,
List<VariableInstanceLifecycleListener<CoreVariableInstance>> lifecycleListeners) {
for (VariableInstanceLifecycleListener<CoreVariableInstance> lifecycleListener : lifecycleListeners) {
protected void initHistoricVariableUpdateEvt(HistoricVariableUpdateEventEntity evt, VariableInstanceEntity variableInstance, HistoryEventType eventType) {
// init properties
evt.setEventType(eventType.getEventName());
evt.setTimestamp(ClockUtil.getCurrentTime());
evt.setVariableInstanceId(variableInstance.getId());
evt.setProcessInstanceId(variableInstance.getProcessInstanceId());
evt.setExecutionId(variableInstance.getExecutionId());
evt.setCaseInstanceId(variableInstance.getCaseInstanceId());
evt.setCaseExecutionId(variableInstance.getCaseExecutionId());
evt.setTaskId(variableInstance.getTaskId());
evt.setRevision(variableInstance.getRevision());
evt.setVariableName(variableInstance.getName());
evt.setSerializerName(variableInstance.getSerializerName());
evt.setTenantId(variableInstance.getTenantId());
evt.setUserOperationId(Context.getCommandContext().getOperationId());
ExecutionEntity execution = variableInstance.getExecution();
if (execution != null) {
ProcessDefinitionEntity definition = execution.getProcessDefinition();
if (definition != null) {
@aravindhrs - I dont think we can truly go by task ID as in some cases it would be empty . Can you please try to set a local variable in servicetask and check if it works .
@aravindhrs - were you able to test the scenario i mentioned and get the desired result.