cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow sent for review, then sent to next user for review

ryangillooly
Champ in-the-making
Champ in-the-making
Hi,

I am trying to implement a new workflow system. What I am trying to find out is,

If i sent a workflow to my manager for example, he reviews it and accepts, can it then be automatically sent to the next selected user or group for review , example HR ?

Any help is much appreciated,
Thanks
3 REPLIES 3

deko
Star Contributor
Star Contributor
Hi there,

You have to setup a listener, that gets active after your manager has completed his review task, which then sets the process variable for Task Assignee to the HR user.

Please note also, that task listeners are an Activiti-specific construct and you should get familiar with Activiti workflows to realize such use cases.

Best regards,
Dennis

ryangillooly
Champ in-the-making
Champ in-the-making
Cheers Denis.

I am now using Eclipse to create the Activiti workflows, but where would i set the listener ?
I am using the diagram view due to not knowing xml very well.
I hope you can help Smiley Happy





<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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="Accepted" name="My process" isExecutable="true">
    <userTask id="alfrescoUsertask1" name="Accepted" activiti:formKey="wf:approvedParallelTask">
      <extensionElements>
        <activiti:taskListener event=" " expression="${listener.listen}">
          <activiti:field name="message">
            <activiti:expression>${message}</activiti:expression>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="alfrescoUsertask2" name="Manager Validation" activiti:formKey="wf:activitiReviewTask">
      <documentation>${assignee} isvalidating request</documentation>
      <extensionElements>
        <activiti:taskListener event="create" expression="${listener.listen}">
          <activiti:field name="Message">
            <activiti:expression>${message}</activiti:expression>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="alfrescoUsertask4" name="Rejected" activiti:formKey="wf:rejectedTask">
      <documentation>Your approval request has been rejected.</documentation>
    </userTask>
    <userTask id="alfrescoUsertask5" name="Accepted" activiti:formKey="wf:approvedTask">
      <documentation>Your approval request has been accepted</documentation>
    </userTask>
    <userTask id="alfrescoUsertask6" name="Director Validation" activiti:formKey="wf:activitiReviewTask">
      <documentation>${listener} is validating request</documentation>
    </userTask>
    <userTask id="alfrescoUsertask7" name="Rejected" activiti:formKey="wf:rejectedParallelTask"></userTask>
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <parallelGateway id="Validation" name="Validation"></parallelGateway>
    <parallelGateway id="Validation2" name="Validation2"></parallelGateway>
    <sequenceFlow id="flow1" name="User Sends For Approval" sourceRef="startevent1" targetRef="alfrescoUsertask2"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="alfrescoUsertask2" targetRef="Validation"></sequenceFlow>
    <sequenceFlow id="acceptanceflow" sourceRef="Validation" targetRef="alfrescoUsertask1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="Validation" targetRef="alfrescoUsertask7"></sequenceFlow>
    <sequenceFlow id="flow5" name="Then Needs Director Validation" sourceRef="alfrescoUsertask1" targetRef="alfrescoUsertask6"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="alfrescoUsertask6" targetRef="Validation2"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="Validation2" targetRef="alfrescoUsertask4"></sequenceFlow>
    <sequenceFlow id="flow14" sourceRef="Validation2" targetRef="alfrescoUsertask5"></sequenceFlow>
    <serviceTask id="alfrescoMailtask1" name="Rejection E-Mail" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string>var mail = actions.create("mail");
mail.execute(bpm_package);</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.to">
          <activiti:string>rgillooly@icas.org.uk</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.from">
          <activiti:string>admin@icas.org.uk</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.subject">
          <activiti:string>workflow Rejection</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.html">
          <activiti:string>Hi,

The workflow has been rejected,

Regards,
ICAS Workflow Management</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <serviceTask id="alfrescoMailtask2" name="Acceptance E-Mail" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string>var mail = actions.create("mail");
mail.execute(bpm_package);</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.html">
          <activiti:string>Hi,

The workflow has been Accepted,

Regards,
ICAS Workflow Management</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.to">
          <activiti:string>rgillooly@icas.org.uk</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.from">
          <activiti:string>admin@icas.org.uk</activiti:string>
        </activiti:field>
        <activiti:field name="mail.parameters.subject">
          <activiti:string>Workflow Acceptance</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow15" name="Sends E-Mail Advising Acceptance" sourceRef="alfrescoUsertask5" targetRef="alfrescoMailtask2"></sequenceFlow>
    <sequenceFlow id="flow16" sourceRef="alfrescoUsertask4" targetRef="alfrescoMailtask1"></sequenceFlow>
    <sequenceFlow id="flow17" name="Sends E-mail Advising Rejection" sourceRef="alfrescoUsertask7" targetRef="alfrescoMailtask1"></sequenceFlow>
    <sequenceFlow id="flow18" sourceRef="alfrescoMailtask2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow19" sourceRef="alfrescoMailtask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Accepted">
    <bpmndi:BPMNPlane bpmnElement="Accepted" id="BPMNPlane_Accepted">
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask1" id="BPMNShape_alfrescoUsertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="300.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask2" id="BPMNShape_alfrescoUsertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="120.0" y="178.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask4" id="BPMNShape_alfrescoUsertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="601.0" y="276.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask5" id="BPMNShape_alfrescoUsertask5">
        <omgdc:Bounds height="55.0" width="105.0" x="601.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask6" id="BPMNShape_alfrescoUsertask6">
        <omgdc:Bounds height="55.0" width="105.0" x="404.0" y="178.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask7" id="BPMNShape_alfrescoUsertask7">
        <omgdc:Bounds height="55.0" width="105.0" x="300.0" y="276.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="0.0" y="188.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="940.0" y="180.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="185.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="550.0" y="185.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoMailtask1" id="BPMNShape_alfrescoMailtask1">
        <omgdc:Bounds height="55.0" width="105.0" x="730.0" y="214.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoMailtask2" id="BPMNShape_alfrescoMailtask2">
        <omgdc:Bounds height="55.0" width="105.0" x="730.0" y="128.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Validation" id="BPMNShape_Validation">
        <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="185.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Validation2" id="BPMNShape_Validation2">
        <omgdc:Bounds height="40.0" width="40.0" x="550.0" y="185.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="35.0" y="205.0"></omgdi:waypoint>
        <omgdi:waypoint x="120.0" y="205.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="-43.0" y="-53.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="225.0" y="205.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="205.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="270.0" y="185.0"></omgdi:waypoint>
        <omgdi:waypoint x="269.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="300.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="270.0" y="225.0"></omgdi:waypoint>
        <omgdi:waypoint x="269.0" y="303.0"></omgdi:waypoint>
        <omgdi:waypoint x="300.0" y="303.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="405.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="456.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="456.0" y="178.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="4.0" y="-6.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="509.0" y="205.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="205.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="570.0" y="225.0"></omgdi:waypoint>
        <omgdi:waypoint x="570.0" y="302.0"></omgdi:waypoint>
        <omgdi:waypoint x="599.0" y="302.0"></omgdi:waypoint>
        <omgdi:waypoint x="601.0" y="303.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="570.0" y="185.0"></omgdi:waypoint>
        <omgdi:waypoint x="570.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="601.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="706.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="128.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="-32.0" y="-47.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="706.0" y="303.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="303.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="269.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="352.0" y="331.0"></omgdi:waypoint>
        <omgdi:waypoint x="352.0" y="375.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="375.0"></omgdi:waypoint>
        <omgdi:waypoint x="782.0" y="269.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="-90.0" y="5.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="835.0" y="155.0"></omgdi:waypoint>
        <omgdi:waypoint x="957.0" y="155.0"></omgdi:waypoint>
        <omgdi:waypoint x="957.0" y="180.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow19" id="BPMNEdge_flow19">
        <omgdi:waypoint x="835.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="957.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="957.0" y="215.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="acceptanceflow" id="BPMNEdge_acceptanceflow">
        <omgdi:waypoint x="270.0" y="185.0"></omgdi:waypoint>
        <omgdi:waypoint x="269.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="300.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Here is exactly what you need:

http://docs.alfresco.com/4.1/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fwf-process-...

In the picture you can see the corresponding code snippet, where a process variable wf_reviewoutcome is written into a log after task completion. YOu just need to adopt this example so that you set the process variable bpm_assignee to a fix user name. Hope I could help!

Dennis