3 Replies Latest reply on Apr 2, 2008 6:03 AM by dleerob

    Multiple Simultaneous Task Instances of the Same Task

    dleerob

      Lets say we have a task node, called "My Node". On that task node, we have a task, called "My Task".

      Lets say now that a manager selects a list of users, could be one user, could be fifty users, that have to now each complete an instance of "My Task". Lets call the number of users he selects 'N'. Is it possible to create 'N' number of task instances of "My Task", each assigned to each of the 'N' number of users selected, so they now all have to finish their "My Task" task instance (simultaneously/in parallell), and the token will only then move forward onto the next node once all 'N' task instances have been completed?

      Anyone know if this is possible with Jbpm, or have any idea how to go about it?

        • 1. Re: Multiple Simultaneous Task Instances of the Same Task
          olivier_debels

          I guess you can do this with an actionHandler.

          see Wfp16MiWithoutAPrioriRuntimeKnowledge.

          • 2. Re: Multiple Simultaneous Task Instances of the Same Task
            dleerob

            Thank you. It tried it out, and it works perfectly.

            In my action class:

             TaskMgmtDefinition tmd =
            (TaskMgmtDefinition) executionContext.getDefinition(TaskMgmtDefinition.class);
             Task task = tmd.getTask("Principal Approval");
             TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
             String[] approvers = new String["actor1","actor2"]; //get desired actors here
             for (int x = 0; x < approvers.length; x++) {
             TaskInstance taskInstance = tmi.createTaskInstance(task, executionContext.getToken());
             taskInstance.setActorId(approvers[x]);
             }
            


            Just remember, in your processdefinition.xml, the <task-node> must have the following attribute if you don't want to create a task instance automatically.
            create-tasks="false"


            Hope this helps someone else.

            • 3. Re: Multiple Simultaneous Task Instances of the Same Task
              dleerob

              I forgot to mention, my action class is fired on node-enter.

              eg:

              <event type="node-enter">
               <action name="Create Document Review Tasks" class="mypackage.CreateDocumentReviewTasks"></action>
              </event>