AnsweredAssumed Answered

Collect documents from users in a workflow

Question asked by oriefeiro on Nov 19, 2009
Latest reply on Dec 6, 2009 by oriefeiro
Hi all, I've implemented a workflow (started automatically) which should collect reports from a group of users.

Here's the workflow definition:


<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="tswf:report">

   <swimlane name="initiator" />
   
   <swimlane name="approver">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
        <actor>admin</actor>
      </assignment>
   </swimlane>

    <start-state name="start">
        <task name="tswf:askForReportTask" swimlane="initiator" />
        <transition name="" to="startcollecting"/>
    </start-state>

    <node name="startcollecting">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reporter</var>
        </action>
        <transition name="report" to="report" />
    </node>

    <task-node name="report">
        <task name="tswf:reportTask">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <actor>#{reporter}</actor>
            </assignment>
      <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
        </event>
      </task>
      <transition name="send" to="endreport">
        </transition>
    </task-node>

    <join name="endreport">
        <transition to="reportscollected" />
    </join>

    <task-node name="reportscollected">
        <task name="tswf:approvedReportTask" swimlane="approver" />
        <transition to="end" />
    </task-node>

    <end-state name="end"/>
   
</process-definition>

The workflow model:


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

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

   <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>

   <namespaces>
      <namespace uri="http://www.alfresco.org/model/testworkflow/1.0" prefix="tswf"/>
   </namespaces>
     
   <types>

      <type name="tswf:askForReportTask">
         <parent>bpm:startTask</parent>
       <mandatory-aspects>
            <aspect>bpm:assignees</aspect>
         </mandatory-aspects>
      </type>
    
     <type name="tswf:reportTask">
         <parent>bpm:workflowTask</parent>
       <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>start_package_item_actions</default>
            </property>
         </overrides>
      </type>
    
     <type name="tswf:approvedReportTask">
         <parent>bpm:workflowTask</parent>
      </type>
    
   </types>
</model>

The start script:


var dataFolder = companyhome.childByNamePath("/reports/data");
if (dataFolder == null)
{
   var reportFolder = companyhome.childByNamePath("/reports");
   dataFolder = reportFolder.createFolder("data");
}
var reporters = people.getMembers(people.getGroup("GROUP_reporters"));
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$tswf:report";
workflow.parameters["bpm:assignees"] = reporters;
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 2);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(dataFolder);

When clicking on the Search button, after that I choose to edit the content package…

[img]http://i47.tinypic.com/15xrdba.jpg[/img]

I get:
org.alfresco.repo.search.SearcherException: Invalid type: {http://www.alfresco.org/model/bpm/1.0}workflowPackage

Outcomes