AnsweredAssumed Answered

How to create stand-alone user task with local variables

Question asked by andrey.nikolov on Jul 19, 2016
Latest reply on Jul 20, 2016 by martin.grofcik
I am trying to create a stand-alone user task which is not associated with any process instance. How could I create local variables to be associated with the new task?

Using the code below we can create and persist the task, but the last call 'CreateVariablesLocal' causes 'lazy loading outside command context' exception due to context check in class 'VariableScopeImpl' method 'ensureVariableInstancesInitialized'.

Please advise!

   TaskEntity taskEntity = (TaskEntity) taskService.newTask();
   taskEntity.createVariablesLocal(… map with variable keys and values …);

   org.activiti.engine.ActivitiException: lazy loading outside command context
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.ensureVariableInstancesInitialized(
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(