cancel
Showing results for 
Search instead for 
Did you mean: 

Task assignment by previous activity performer

preetigupta
Champ in-the-making
Champ in-the-making
Hi All,

I am new to Alfresco, so have the following doubt.

I have a requirement where the next activity performer should be decided by current activity performer.

Say, there are these activities
Start-> Peer Review -> Supervisor -> Approver -> End

The initiator would select the performer of activity Peer Review. Now, my requirement is that when Peer Review completes his activity he should select from the users who would be performing Supervisor activity.

I hope I am clear in my requirement.

Thanks in advance.

Best Regards
Preeti Gupta
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
The Alfresco jBPM engine can handle this. If you don't already understand how workflows are defined and how workflow metadata is exposed to the web client UI, you need to take a look at either the workflow tutorial at http://ecmarchitect.com/archives/2007/11/19/785 or Chapter 7 in the Alfresco Developer Guide book.

Once you have a general understanding of that, you can dig in to the out-of-the-box workflow and basically repeat what they've done for the start workflow task for each task in which you need to make an assignment.

Take a look at alfresco/WEB-INF/classes/alfresco/workflow/submit_processdefinition.xml. It's a WCM-related workflow but it doesn't matter–the technique is the same for both WCM and DM. In it we see a task called "wcmwf:submitReviewTask":

<start-state name="start">
        <task name="wcmwf:submitReviewTask" swimlane="initiator"/>
        <transition name="" to="initialise"/>
</start-state>

Now go to alfresco/WEB-INF/classes/alfresco/workflow/wcmWorkflowModel.xml to find the type that corresponds to the task name:

<type name="wcmwf:submitReviewTask">
      <parent>wcmwf:startTask</parent>
      <properties>
        <property name="wcmwf:submitReviewType">
          <title>Serial or Parallel Review</title>
          <type>d:text</type>
          <mandatory>true</mandatory>
          <default>Serial</default>
          <constraints>
            <constraint ref="wcmwf:reviewType" />
          </constraints>
        </property>
      </properties>
      <mandatory-aspects>
        <aspect>bpm:assignees</aspect>
        <aspect>wcmwf:webproject</aspect>
        <aspect>wcmwf:submission</aspect>
      </mandatory-aspects>

See that "bpm:assignees" aspect? It is defined in alfresco/WEB-INF/classes/alfresco/model/bpmModel.xml. It's what keeps track of the people assigned to this workflow in the submit review task.

How does Alfresco know to show the user/group picker when this workflow is launched? It is defined in alfresco/WEB-INF/classes/alfresco/web-client-config-properties.xml:

<config evaluator="node-type" condition="wcmwf:submitReviewTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="wf_review_options" component-generator="HeaderSeparatorGenerator" />
         <show-property name="wcmwf:submitReviewType"/>
         <separator name="sep2" display-label-id="users_and_roles" component-generator="HeaderSeparatorGenerator" />
         <show-association name="bpm:assignees" display-label-id="wf_reviewers" />
      </property-sheet>

So alfresco uses web-client-config to figure out which properties to show for a given type. In the case of a workflow, the type corresponds to a task node in the process definition. Alfresco presents the form to capture the metadata, then persists it to properties as defined in the workflow's data model (just like a "normal" content model).

Turning our attention back to the process definition, we can see one of several places where the definition refers to "bpm_assignees" to see who was picked in the UI. Alfresco automatically makes the workflow's metadata available as process variables. The property "bpm:assignees" gets its name changed to "bpm_assignees":

<task-node name="serialreview">
        <task name="wcmwf:reviewTask">
          <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>#{bpm_assignees.get(wcmwf_approveCnt)}</actor>
           </assignment>
           <event type="task-assign">
              <script>
                 if (wcmwf_reviewCycle > 1)
                    taskInstance.description = taskInstance.description + " (" + wcmwf_reviewCycle + ")";
              </script>
           </event>          
        </task>
        …SNIP…

You should be able to repeat this pattern (using your own task names, types, aspects, and properties) to capture any metadata you want, including user/group assignment information, on the task management page for any step in your workflow.

Jeff

preetigupta
Champ in-the-making
Champ in-the-making
Hi Jeff,

Thanks for the knowledge. I have tried the concept, and got the results.

Best Regards,
Preeti Gupta