cancel
Showing results for 
Search instead for 
Did you mean: 

Display variables control in a Form

fstnboy
Champ on-the-rise
Champ on-the-rise
Hi,

I'm using the Activiti6Beta2 community version.

I'm trying to display the value of some variables in a form. For this, I'm the display value control and setting the variable name as "${myVar}".

It seems like it works for a variable that's been set in the start form. But for variables created within the process it doesn't work.

I've got the following ScriptTask to set process variables, and I've printed the values at a later stage and they are set properly:


<scriptTask id="retrieveInformation" name="Get Info" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script><![CDATA[
execution.setVariable('account','My Account');
execution.setVariable('limit','3000');
execution.setVariable('performer','Michael Jackson');]]></script>
    </scriptTask>


But the form displaying the values shows '(empty)'. I've even tried creating task variables at a task listener script on the user task with no luck


<activiti:taskListener event="create" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
task.setVariable('account',"My Activiti account");
limit="15000";
performer="Someone";]]></activiti:string>
          </activiti:field>
          <activiti:field name="language">
            <activiti:string>javascript</activiti:string>
          </activiti:field>
        </activiti:taskListener>


Any ideas? I know this is a Beta version, just wondering if this should be working.
3 REPLIES 3

fstnboy
Champ on-the-rise
Champ on-the-rise
When calling the rest API to retrieve the variables: runtime/process-instances/{processInstanceId}/variables

They are all returned with the corresponding values.

Same when calling the tasks variables API: runtime/tasks/{taskId}/variables?scope={scope}

<javascript>
[
  {
    "name": "existsInSystem",
    "type": "boolean",
    "value": true,
    "scope": "global"
  },
  {
    "name": "paymentDocument",
    "value": null,
    "scope": "global"
  },
  {
    "name": "backendSystem",
    "type": "string",
    "value": "EVEREST",
    "scope": "global"
  },
  {
    "name": "initiator",
    "type": "string",
    "value": "1",
    "scope": "global"
  },
  {
    "name": "performer",
    "type": "string",
    "value": "Michael Jackson",
    "scope": "global"
  },
  {
    "name": "paymentReference",
    "type": "string",
    "value": "asdf",
    "scope": "global"
  },
  {
    "name": "limit",
    "type": "string",
    "value": "3000",
    "scope": "global"
  },
  {
    "name": "account",
    "type": "string",
    "value": "My Account",
    "scope": "global"
  }
]
</javascript>

jbarrez
Star Contributor
Star Contributor
So from those list, which one is one from the start form that works?
But you are correct, both should work just as-is, irregardless where they came from.

fstnboy
Champ on-the-rise
Champ on-the-rise
Thanks for coming back to me.

From the list paymentReference and paymentDocument are the ones filled in the start form. I just ignored paymentDocument field because I didn't find a OOTB way to show a document in the Beta version.