cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using initiator

bhj2
Champ in-the-making
Champ in-the-making
Hello,

I created my own version of the explorer and my own bpmn2.0 process. The problem is about the initiator. I want the task to be assigned to the initiator of the process but that works… SOMETIMES!! It's random.

Here is my bpmn process:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:activiti="http://activiti.org/bpmn" targetNamespace="EGovRunnerProcesses">

   <process id="MyTestProcess" name="MyTest Process">
      <startEvent id="theStart" activiti:initiator="initiator">
         <extensionElements>
            <activiti:formProperty id="person" type="string" />
            <activiti:formProperty id="reason" type="string" />
         </extensionElements>
      </startEvent>

      <sequenceFlow id='flow1' sourceRef='theStart' targetRef='writeSomethingTask' />

      <userTask id="writeSomethingTask" name="Write something" activiti:formKey="ch/glue/egovrunner/processes/MyTestForm.form" activiti:assignee="${initiator}">
         <documentation>
            Write something.
            </documentation>
      <extensionElements>
      <activiti:taskListener event="create" class="ch.glue.egovrunner.explorer.listeners.OsisTaskCreateListener" />
        </extensionElements>
      </userTask>

      <sequenceFlow id='flow2' sourceRef='writeSomethingTask' targetRef='theEnd' />

      <endEvent id="theEnd" />
   </process>

</definitions>

and here is the java method I use to start the process:
/**
    * Start a instance which has a start form.
    *
    * @param processDefinition
    *            the process definition to start
    * @param formData
    *            the form data filled by the user
    */
   public void submitStartForm(ProcessDefinition processDefinition,
         Map<String, String> formData) {
      ProcessInstance pi = getFormService().submitStartFormData(
            processDefinition.getId(), generateBusinessKey(), formData);
      
      processLayout.showProcessStartSuccess(processDefinition);
   }

I tested with always the same process definition and always the same content in formData but the initiator is sometimes null and sometimes ok.

Do you have an idea?
10 REPLIES 10

trademak
Star Contributor
Star Contributor
Looks like a decent approach yes.

Best regards,