cancel
Showing results for 
Search instead for 
Did you mean: 

Execution variable data type

jurgisl
Champ in-the-making
Champ in-the-making
Hi,

I'm developing a complex workflow using Activiti engine. And I'm struggling with execution variables in the Javascript task listener scripts. I could not find what data types execution.setVariable function accepts, but it seems that it accepts only String data types.

I have a workflow where in one of the middle steps I get multiple assignees, for the next multi instance User Task. I want to store them as an Execution variable, because they will be needed in following tasks. But following code throws an error:

java.lang.ClassCastException: org.alfresco.repo.workflow.activiti.ActivitiScriptNode cannot be cast to java.lang.String


    <userTask id="p_1_3" name="…" activiti:assignee="${wf_responsible}" activiti:formKey="wf:assignCreateResponseTask">
      <extensionElements>
       <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>
              execution.setVariable('wf_assignees', task.getVariable('wf_assignees'));

If I put their usernames in an array and join them with commas, later split them for multi instance loop user task. Another error is thrown, that activiti:collection requires data type Collection. And I found no way to cast javascript native array to Collection data type.

How can I store multiple assignees in a execution variable?
Does this question relate more to Alfresco or Activiti?
1 REPLY 1

jurgisl
Champ in-the-making
Champ in-the-making
Ok, got it working. All that was needed was to call the .toString() function, like:
execution.setVariable('wf_assignees', task.getVariable('wf_assignees').toString());

Strange, that it throws an error, complaining that it cannot cast this value to a String, but the object has a standard function to do so. Maybe there are again some Java to Javascript data type mismatches.