6 Replies Latest reply on Jul 28, 2010 8:43 PM by HuiSheng Xu

    Capturing the initiator user

    Klaus Dworschak Newbie

      I am trying to capture the name of the user who started a task.

      Until now I only found some documentation about how do to this in jBPM v3.


      Here's my question: What's the best way to do that in jBPM v4?



      Thank you!

        • 1. Re: Capturing the initiator user
          Jorge Ferreira Newbie

          Disclaimer: jBPM 4.3 does not support historic on task reassignment. This means if task task1 is first assigned to user homer, then it is delegated manually or otherwise to user bart and finally to user marge, jBPM will only keep track of the last user, marge in this case, that was assigned to task1.


          Having said that, if you are ok with getting the currently user assigned to a task you can use TaskService to create a TaskQuery filtering by process instance id and task name, as in the following example:


          TaskService taskService = ...;

          String processInstanceId = ...;

          TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstanceId).activityName("task1");
          Task task = taskQuery.uniqueResult();
          // task.getAssignee() contains the login of the user, if any, to which the task is assigned to.
          • 2. Re: Capturing the initiator user
            Klaus Dworschak Newbie

            What I meant was workflow not task. Sorry for that.


            I want to "capture" the user that started the whole workflow. I need a way for this user to keep track of workflows he started and for him to see which states that workflows are currently in.

            • 3. Re: Capturing the initiator user
              Michael Wohlfart Expert

              did you try using a swimlane for that?

              • 4. Re: Capturing the initiator user
                Klaus Dworschak Newbie

                Can you please give me an example of how to do this in jBPM v4?


                All examples I've found so far use jBPM v3 syntax (e.g. <start-state>, etc).


                I've tried the following xml but i guess I'm doing it completely wrong.



                <swimlane name="initator" assignee="${requestor}" />

                <task name="TestTask" candidate-groups="${testTaskGroup1}" swimlane="initator" >

                    <transition to="end"/>


                • 5. Re: Capturing the initiator user
                  Charles Aznavour Newbie

                  Hi Klaus,


                  we had the same requirement. We use jbpm 4.4 and create a histroy variable on process start:



                  String userId = ...

                  ProcessInstance processInstance = ....

                  executionService.createVariable(processInstance.getId(), "initiatior", userId, true);



                  The "true" makes this variable a history variable. Especially useful as you could query the database for it (we do it outside of jbpm), even for ended processes. As we also need the initiator in a swimlane during process intatiation, so we additionally pass this value as a regular process parameter in the startProcessInstance method.




                  1 of 1 people found this helpful
                  • 6. Re: Capturing the initiator user
                    HuiSheng Xu Master

                    Hi guys,


                    We really want to support this feature in the next version of jBPM 4.  Please join our discussion and give us your advices,  Thank you very much.


                    The post is here.