cancel
Showing results for 
Search instead for 
Did you mean: 

bpm:assignee aspect not mandatory

coyoteugly
Champ in-the-making
Champ in-the-making
Hi, I'm performing some training tests on Alfresco advanced workflow using activiti. I'm able to create a simple workflow using use the bpm:assignee aspect. Anyway, to implement this I use the following code on my workflowModel-custom.xml :

<mandatory-aspects>
   <aspect>bpm:assignee</aspect>
</mandatory-aspects>

Due to complete an example workflow I'm actually developing, how is possible to use the bpm:assignee as a non-mandatory-aspect ? I want to show an optional form that permit to the user to assignee the next step of my workflow, but not mandatory, I need it optional!!

Thanks!!
3 REPLIES 3

rajeshavatani
Champ in-the-making
Champ in-the-making
Please share your process definition and workflow content model and let me know exactly you are trying to achieve.

coyoteugly
Champ in-the-making
Champ in-the-making
Hi rajeshavatani,
this is my process definition:

<?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="myTest" name="My Test" isExecutable="true">
    <startEvent id="start" name="Start" activiti:formKey="wf:submitMyTest"></startEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <userTask id="myTestUT2" name="My Test UT2" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:myTestUT2"></userTask>
    <userTask id="myTestUT3" name="My Test UT3" activiti:assignee="paperino" activiti:formKey="wf:myTestUT3"></userTask>
    <userTask id="myTestUT4" name="My Test UT4" activiti:assignee="paperone" activiti:formKey="wf:myTestUT4"></userTask>
    <endEvent id="end" name="End"></endEvent>
    <userTask id="myTestUT5" name="My Test UT5" activiti:assignee="topolino" activiti:formKey="wf:myTestUT5"></userTask>
    <sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="exclusivegateway1" targetRef="myTestUT2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="myTestUT3"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="myTestUT2" targetRef="myTestUT4"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="parallelgateway1" targetRef="myTestUT5"></sequenceFlow>
    <userTask id="myTestUT1" name="My Test UT1" activiti:assignee="admin" activiti:formKey="wf:myTestUT1">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('bpm_assignee', task.getVariable('bpm_assignee'));</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow10" sourceRef="start" targetRef="myTestUT1"></sequenceFlow>
    <sequenceFlow id="flow11" sourceRef="myTestUT1" targetRef="parallelgateway1"></sequenceFlow>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow12" sourceRef="myTestUT3" targetRef="myTestUT4"></sequenceFlow>
    <sequenceFlow id="flow13" sourceRef="myTestUT4" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow14" sourceRef="myTestUT5" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow15" sourceRef="parallelgateway2" targetRef="end"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myTest">
    <bpmndi:BPMNPlane bpmnElement="myTest" id="BPMNPlane_myTest">
      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
        <omgdc:Bounds height="35.0" width="35.0" x="20.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="270.0" y="127.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="370.0" y="127.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="myTestUT2" id="BPMNShape_myTestUT2">
        <omgdc:Bounds height="55.0" width="105.0" x="440.0" y="37.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="myTestUT3" id="BPMNShape_myTestUT3">
        <omgdc:Bounds height="55.0" width="105.0" x="440.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="myTestUT4" id="BPMNShape_myTestUT4">
        <omgdc:Bounds height="55.0" width="105.0" x="580.0" y="120.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
        <omgdc:Bounds height="35.0" width="35.0" x="713.0" y="350.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="myTestUT5" id="BPMNShape_myTestUT5">
        <omgdc:Bounds height="55.0" width="105.0" x="237.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="myTestUT1" id="BPMNShape_myTestUT1">
        <omgdc:Bounds height="55.0" width="105.0" x="110.0" y="120.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="710.0" y="287.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="310.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="370.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="390.0" y="127.0"></omgdi:waypoint>
        <omgdi:waypoint x="390.0" y="65.0"></omgdi:waypoint>
        <omgdi:waypoint x="440.0" y="64.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="390.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="390.0" y="228.0"></omgdi:waypoint>
        <omgdi:waypoint x="440.0" y="227.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="545.0" y="64.0"></omgdi:waypoint>
        <omgdi:waypoint x="542.0" y="77.0"></omgdi:waypoint>
        <omgdi:waypoint x="632.0" y="77.0"></omgdi:waypoint>
        <omgdi:waypoint x="632.0" y="120.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="290.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="289.0" y="280.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="55.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="110.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="215.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="545.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="632.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="632.0" y="175.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="685.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="730.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="730.0" y="287.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="342.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="710.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="730.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="730.0" y="350.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


and this is my workflow content model

<?xml version="1.0" encoding="UTF-8"?>

<model name="wf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <imports>
      <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0"
         prefix="d" />
      <!– Import Alfresco System Definitions –>
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
      <!– Import User Model Definitions –>
      <import uri="http://www.alfresco.org/model/user/1.0" prefix="usr" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
   </imports>

   <namespaces>
      <namespace uri="http://www.alfresco.org/model/workflow/1.0"
         prefix="wf" />
   </namespaces>

   <types>

      <type name="wf:submitMyTest">
         <parent>bpm:startTask</parent>
 
      </type>
 
<type name="wf:myTestUT1">
             <parent>bpm:activitiOutcomeTask</parent>
             <properties>
                 <property name="wf:reviewOutcome">
                     <type>d:text</type>
                     <default>Reject</default>
                     <constraints>
                         <constraint name="wf:reviewOptions" type="LIST">
                             <parameter name="allowedValues">
                                 <list>
                                     <value>Approve</value>
                                     <value>Reject</value>
                                 </list>
                             </parameter>
                         </constraint>
                     </constraints>
                 </property>
             </properties>
             <overrides>
                 <property name="bpm:packageItemActionGroup">
                     <default>edit_package_item_actions</default>
                 </property>
                 <property name="bpm:outcomePropertyName">
                     <default>{http://www.alfresco.org/model/workflow/1.0}reviewOutcome</default>
                 </property>
             </overrides>            
             
                 <mandatory-aspects>
                    <aspect>bpm:assignee</aspect>
                 </mandatory-aspects>

        </type>           
 
      <type name="wf:myTestUT2">
         <parent>bpm:workflowTask</parent>

      </type>
      
      <type name="wf:myTestUT3">
               <parent>bpm:workflowTask</parent>

      </type>
      
            <type name="wf:myTestUT4">
                     <parent>bpm:workflowTask</parent>
            
      </type>

            <type name="wf:myTestUT5">
                     <parent>bpm:workflowTask</parent>
            
      </type>

   </types>

   <aspects>

   </aspects>

</model>


This is only a low level fictitious example I'm trying to develop due to learn bpml and activiti from the base.
In my flow, after the User Task named "myTestUT1" I have an exclusive gateway. If the result of Exclusive gateway is "Approve", the flow choose the route to "myTestUT2" and the task is assigned to an user selected using the assegnee property in the previus Form. Anyway, if the the result of Exclusive gateway is "Reject", the flow proceed to "myTestUT3" assigned to a default user, so I do not need to use the assegnee aspect to choose the user.
There is a way to use the assegnee aspect as an optional aspect and not mandatory?

Thanks a lot, regards !

assignee is mandatory for a user task. I assume by default user you mean initiator, you can assign the user task to ${initiator.properties.userName}.

If it's not initiator then you can set the default user to a process variable and then assignee the user task to default user.

Hope this helps!!