AnsweredAssumed Answered

Usertask automatically executed

Question asked by wmoons on Dec 20, 2011
Hi,

I have made a little flow in Activiti designer and I'm now trying to get it executed in Alfresco.
When I execute the flow, the first  usertask is executed automatically which should not happen as the user needs to give in a value.

My bpmn file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="MyTestProcess" name="MyTestProcess">
    <documentation>Place documentation for the 'MyTestProcess' process here.</documentation>
    <exclusiveGateway id="exclusivegateway1" name="Report for marketing"></exclusiveGateway>
    <userTask id="usertask1" name="Review report" activiti:assignee="wmoons" activiti:formKey="loc:activitireportreview">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>/* next two lines are workarounds ACT-765, ACT-766 */
if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>if(task.getVariableLocal('isMarketing') == 'Yes') {
execution.setVariable('Marketing', 'Yes');
}
else{
execution.setVariable('Marketing', 'No');
}</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" name="" sourceRef="exclusivegateway1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${Marketing == 'Yes'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask2" name="Read marketing report" activiti:candidateGroups="Marketing"></userTask>
    <userTask id="usertask3" name="Read report" activiti:candidateGroups="Sales"></userTask>
    <sequenceFlow id="flow4" name="" sourceRef="exclusivegateway1" targetRef="usertask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${Marketing == 'No'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow6" name="" sourceRef="usertask3" targetRef="endevent2"></sequenceFlow>
    <sequenceFlow id="flow7" name="" sourceRef="usertask1" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow9" name="" sourceRef="usertask2" targetRef="endevent2"></sequenceFlow>
    <startEvent id="startevent1" name="Start"></startEvent>
    <sequenceFlow id="flow10" name="" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">
      <script><![CDATA[var Marketing = 'No';]]></script>
    </scriptTask>
    <sequenceFlow id="flow11" name="" sourceRef="scripttask1" targetRef="usertask1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_MyTestProcess">
    <bpmndi:BPMNPlane bpmnElement="MyTestProcess" id="BPMNPlane_MyTestProcess">
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40" width="40" x="600" y="87"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="420" y="80"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55" width="105" x="770" y="80"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55" width="105" x="568" y="173"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35" width="35" x="790" y="260"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="200" y="90"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="290" y="80"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="640" y="107"></omgdi:waypoint>
        <omgdi:waypoint x="770" y="107"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="620" y="127"></omgdi:waypoint>
        <omgdi:waypoint x="620" y="173"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="620" y="228"></omgdi:waypoint>
        <omgdi:waypoint x="807" y="260"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="525" y="107"></omgdi:waypoint>
        <omgdi:waypoint x="600" y="107"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="822" y="135"></omgdi:waypoint>
        <omgdi:waypoint x="807" y="260"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="235" y="107"></omgdi:waypoint>
        <omgdi:waypoint x="290" y="107"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="395" y="107"></omgdi:waypoint>
        <omgdi:waypoint x="420" y="107"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

my model file:

<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="loc:workflowmodel"
   xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Test Workflow</description>
   <author>Wim Moons</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0"
         prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0"
         prefix="bpm" />
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.loqutus.be/model/workflow/1.0"
         prefix="loc" />
   </namespaces>

   <types>
   <type name="loc:reportreview">
            <parent>bpm:workflowTask</parent>
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>read_package_item_actions</default>
                </property>
            </overrides>
        </type>
   
        <type name="loc:activitireportreview">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="loc:isMarketing">
                    <type>d:text</type>
                    <default>No</default>
                    <constraints>
                        <constraint type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Yes</value>
                                    <value>No</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>              
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>read_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{http://www.loqutus.be/model/workflow/1.0}YesNoOutcome</default>
                </property>
            </overrides>
        </type>
</types>
</model>

Outcomes