AnsweredAssumed Answered

User task forms do not map custom variables

Question asked by francesco.lilli on Sep 7, 2013
Latest reply on Sep 14, 2013 by francesco.lilli

I am new to Activiti.
I am developing my first workflow, and the flow just work as a charm, but I am stuck with an apparently stupid problem.

First I want to set execution variables into the ScriptExecutionListener of the "start" event:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="" xmlns:xsi="" xmlns:activiti="" xmlns:bpmndi="" xmlns:omgdc="" xmlns:omgdi="" typeLanguage="" expressionLanguage="" targetNamespace="">
  <process id="signatureCycle" name="Signature Cycle" isExecutable="true">
     <startEvent id="start" name="Start" activiti:formKey="wf:signatureCycle">
      <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
         execution.setVariable('wf_sect', 'AAA');
         execution.setVariable('wf_dt', 'BBB');

Now I want to see the values I just set into the corresponding form label fields (i.e., "AAA" into "wf:sect", and "BBB" into "wf:dt"). This is (part of) the workflow model configuration:

<?xml version="1.0" encoding="UTF-8"?>
<model name="wf:workflowmodel" xmlns="">
      <import uri="" prefix="d"/>
      <import uri="" prefix="bpm"/>
      <namespace uri="" prefix="wf"/>
      <type name="wf:signatureCycle">
      <aspect name="wf:docInfo">
         <property name="wf:sect">
         <property name="wf:dt">

And this is (part of) the share workflow form configuration:

    <config evaluator="string-compare" condition="activiti$signatureCycle">
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="wf:sect" />
               <show id="wf:dt" />
               <show id="bpm:comment" />
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="abs" appearance="title" label-id="workflow.set.abs" />
               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 60%</control-param>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due"
                  set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority"
                     template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               <field id="wf:sect" set="abs">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               <field id="wf:dt" set="abs">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               <field id="bpm:comment" label-id="workflow.field.comment"
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />

I can't see the values into the form, but I know they are actually stored. I tried to get the values as input from the form (transforming the labels into input fields), everything works just fine as the variables are stored. In fact, if I do:



the logs show the right values (i.e., "AAA" and "BBB" respectively), both setting them hard-coding and from user input. The only problem is that in the form I see:

wf:sect: (None)
wf:dt: (None)

I also tried to set values into an executionListener of the process itself, instead of in the executionListener of the start task: any form just won't show anything, just those annoying None's.
Oddly enough, though, the "Workflow Details" view shows those values without problems (even though it seems to me that once set for the first time they never change, even after resetting the variables programmatically with execution.setVariable('wf_sect', 'NEWVALUE1') and execution.setVariable('wf_dt', 'NEWVALUE2')).
Any suggestions?