cancel
Showing results for 
Search instead for 
Did you mean: 

Collect documents from users in a workflow

oriefeiro
Champ in-the-making
Champ in-the-making
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
4 REPLIES 4

notherien
Champ in-the-making
Champ in-the-making
hi,try to replace

<type name="tswf:reportTask">
         <parent>bpm:workflowTask</parent>
       <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>start_package_item_actions</default>
            </property>
         </overrides>
      </type>
by
   <type name="tswf:reportTask">
         <parent>bpm:workflowTask</parent>
       <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>

oriefeiro
Champ in-the-making
Champ in-the-making
sorry but this doesn't resolve the problem… if I 'edit' the package I get the same mask which ask to search for a doc in the repository and if I click Search I get the exception…. Smiley Frustrated
the thing i'd like to do is to ADD a package item, but add_package_item_actions doesn't work… is the problem the package itself??? what should i start the workflow with?

hyperation
Champ on-the-rise
Champ on-the-rise
Hi,

Looks like the start script is trying to execute the workflow on a "folder"?  I'm not sure if that is possible.


Thanks,
Smiley Happy

oriefeiro
Champ in-the-making
Champ in-the-making
Hi, yes that's possible but useless Smiley Wink Anyway, I have found somewhere in this forum that it's possibile to trigger a workflow on an empty package, I'll keep on experimenting…