cancel
Showing results for 
Search instead for 
Did you mean: 

how to set a variable in startevent?

miraclesuki
Champ in-the-making
Champ in-the-making
I want to get the property value "mcwf:status" from the model in startevent. Then I need to pass the value of "mcwf:status" to other forms.

Below is the code, it does not printout the variable, it seems that the part of extensionElemnts has not been run?

The snippet of the bpmn diagram:
<blockcode>
<startEvent id="startevent1" name="Start" activiti:formKey="mcwf:submitReviewTask">
    <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[
                        var newstatus = task.getVariableLocal('mcwf_status');
                        execution.setVariable('mcwf_newstatus', newstatus);
                        logger.log("AAAAAAAAA      " + newstatus);
                    ]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </startEvent>
</blockcode>
The snippet of the model file:
<blockcode>
<aspect name="mcwf:status">
            <title>Status</title>
            <properties>
                <property name="mcwf:status">
                    <title>Status</title>
                    <type>d:text</type>
                    <default>0</default>
                    <constraints>
                        <constraint type="LIST">
                          <parameter name="allowedValues">
                            <list>
                            <value>100</value>
                            <value>200</value>
                            </list>
                          </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>
        </aspect>
</blockcode>
If I change the startevent to usertask, then I copy the code of extensionElements and paste instead of it, and don't know why it can be work properly.

Thanks.
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
(Activiti Developers forum is meant for contributors to Activiti)

a task listener on a start event will not work. A start event is no usertask.

You will need to use an executionListener instead.