cancel
Showing results for 
Search instead for 
Did you mean: 

How to make variables persistent?

upforsin
Star Collaborator
Star Collaborator

Hello,

I have defined an Activiti process and I can not force variables to be persistent across whole process (they just "evaporate")!

Let's say I have "san:value" property defined in mainUserTask type in workflowModel.xml.

Every other task is a child of this mainUserTask.

Now, in the Alfresco Share, in the user task I enter the value of "san:value" and click "Task done".

In the next task, I want to have the same input field with the value I entered earlier. But the value is empty! Why?

I managed to solve the problem by declaring a TaskListener which gets variable from task and saves it to the execution.

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('san_value', task.getVariable('san_value'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

But do I really have to do it in every single task with every single variable?

The next problem is, that in the "Workflow Detalis" view, those variables are empty...

Anyone has an idea how this can be fixed?

I also tried calling Java class in the taskListener and instantiate variables there but with the same result.

String myprocessinstanceid = delegateTask.
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService myruntimeservice = processEngine.getRuntimeService();
myruntimeservice.setVariable(myprocessinstanceid, "san_value", delegateTask.getVariable("san_value"));‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Regards,

Mike

howkymike
Alfresco Developer
1 REPLY 1

upforsin
Star Collaborator
Star Collaborator

Ok, i believe there is NO way to achieve that. Workflow History view displays only the history and tt was designed not to be edited...

howkymike
Alfresco Developer