3 Replies Latest reply on Feb 28, 2011 12:35 PM by helal jean-noel

    how to assign assignee to a task at run time

    Ayusman Dikshit Newbie

      All,

      I have a scenario where I want to assign users to a task at runtime.

      Meaning.. when the workflow reaches the task at somepoint in time during execution, i want users to be selected and assigned based on a database lookup.

       

      my questions:

      1. is assignment-handler in a <task> element the right way to achieve this jbpm 4.4?

      2. is there any way this can be achieved?

      3. Do I need to have these users and groups listed in the jbpm identity tables?

       

      Please help...

       

      Thanks,

      Ayusman

        • 1. how to assign assignee to a task at run time
          helal jean-noel Newbie

          Please readout the 4.4 user guide and the task node attribute description

           

          Assuming the user is named "ayusman" You may set <task mame="myTask" assignee="ayusman" ..> into the process définition.

          When "myTask" is reached, the task can be queried among others as "assigned to ayusman" with something like

               TaskService.createQuery().assignee("ayusman").list()

           

          Same holds with "candidate" attribute.

           

          Same principle again with "candidate-goups" attributes but this time you have to set a group and membership "ayousman" to it

           

          Regards

          jnh

          • 2. how to assign assignee to a task at run time
            Ayusman Dikshit Newbie

            Thanks jnh

            this I have tried. What I wanted to ask is:

             

            So are you suggesting, if my task is reached (say my task is 10 task element in the workflow)  2 days after the process instance is initiated.

             

            The actual users assigned to this task is evaluated 2 days after the task is started. Is my understanding correct?

             

            Thanks,

            Ayusman

            • 3. how to assign assignee to a task at run time
              helal jean-noel Newbie

              There is no time delay to consider.

               

              If a user is assigned to a task directly into the process definition through the task note (<task name="MyTask" assignee = "Ayusman") and

              the process exection reachs the task node "MyTask" then:

               

              the task note instance of "MyTask" can be queried as one of those assigned to "Ayusman" from that moment: hat is TaskService.createQuery().assignee("ayusman").list() will return the task node "MyTask" of that process instance (among possible others task node instances), allowing you to step forward programatically.

               

              So if i'm understanding your question: yes if the task node is reach 2 days after the process instance has started, the task is assigned exactly two days after too. But please remark that it is rather the task node that is assigned '(among possible others) to the user. What you are doing programmatically then is: 1/ query all tasks that are assigned to the person currently connected to your app and 2/ display tasks for possible step forward to the user (some buttons and fields triggering Task.completetask() method).

               

              Regards