3 Replies Latest reply on Aug 14, 2011 4:14 PM by salaboy21

    (User Tasks) How to get user tasks by process instance?

    a.d.jbpm

      Hi,

      Is there any way to get user tasks by process instance?

      Unfortunately, available methods in TaskClient enable to get tasks only by user:

      1. taskClient.getTasksAssignedAsPotentialOwner(user, language, handler);
      2. taskClient.getTasksAssignedAsPotentialOwner(user, groupIds, language, handler);

       

      Thanks,

        • 1. Re: (User Tasks) How to get user tasks by process instance?
          salaboy21

          you usually build your task lists oriented interfaces using the user that is logged to retrieve his/her tasks. Why do you want to query the task generated by a process instance?

           

          Can you elaborate on your business case?

          • 2. Re: (User Tasks) How to get user tasks by process instance?
            a.d.jbpm

            I have several executing instances of a process X (for instance, 4 executing instances).

            When I invoke 'taskClient.getTasksAssignedAsPotentialOwner("john",...)', I get assigned tasks for 'john' in all different running instances. However, I am interesting to retrieve only john's tasks in instance id=3.

            • 3. Re: (User Tasks) How to get user tasks by process instance?
              salaboy21

              I know, that's the idea, but if you create a task list john will see all his tasks and he will be able to choose in which task to work. If you want to know from the history logs which process create each task you have the Task.TaskData.workItemId reference that helps you to find the process where that task instance was created. Notice that there is a named query defined for that reason:

              <named-query name="TaskByWorkItemId">

                        <query>

              select

                  t

              from

                  Task t

              where

                  t.taskData.workItemId = :workItemId

                        </query>

                        <!-- hint name="org.hibernate.timeout" value="200"/ -->

                    </named-query>

               

              Cheers