cancel
Showing results for 
Search instead for 
Did you mean: 

Historic FormProperties

ronnybr
Champ in-the-making
Champ in-the-making
Hell Activiti-Community,

I have a little problem with the HistoryService and HistoricFormProperties.

According to the User Guide this Query:

historyService.createHistoricDetailQuery()
  .formProperties()
  .processInstanceId("123")
  .orderByVariableName().asc()
  .list()
should get
[…] all form-properties that were submitted in any task or when starting the process with id "123"

My own query looks like this:
      String processInstanceId = historyService
            .createHistoricTaskInstanceQuery().taskId(taskId)
            .singleResult().getProcessInstanceId();
      List<HistoricDetail> historicFormProperties = historyService
            .createHistoricDetailQuery()
            .processInstanceId(processInstanceId).formProperties()
            .orderByTime().desc().list();
and the XML of my Start-Element like this:

    <startEvent id="_8" isInterrupting="true" name="neues Praxissemester" parallelMultiple="false">
      <extensionElements>
        <activiti:formProperty id="student" name="Student" required="true" type="string" variable="student"/>
        <activiti:formProperty id="studentMail" name="Student-Mail-Adresse" required="true" type="string" variable="studentMail"/>
        … more FormProperties
    </startEvent>

So when starting the process and calling the method with the HistoryService it doesn't deliver any HistoricFormProperties. After finishing the first task in the process (which also has one FormProperty) the HistoryService only delivers that one.

Do I forget another necessary parameter when building the query or is it a problem within Activiti?
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
So you're saying that start-form properties aren't recorded in history, but task-form-properties are? Seems strange, normally, when historyLevel=full, ALL form-properties should be recorded.

We have a test that validates this:

http://svn.codehaus.org/activiti/activiti/tags/activiti-5.0/modules/activiti-engine/src/test/java/or...


  Map<String, String> formProperties = new HashMap<String, String>();
    formProperties.put("formProp1", "Activiti rocks");
    formProperties.put("formProp2", "12345");
   
    ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicFormPropertiesProcess").singleResult();
   
    ProcessInstance processInstance = formService.submitStartFormData(procDef.getId() , formProperties);

   …

// 4 historic form properties should be created. 2 when process started, 2 when task completed
    List<HistoricDetail> props = historyService.createHistoricDetailQuery()
      .formProperties()
      .processInstanceId(processInstance.getId())
      .orderByFormPropertyId().asc()
      .list();
   
    HistoricFormProperty historicProperty1 = (HistoricFormProperty) props.get(0);
    assertEquals("formProp1", historicProperty1.getPropertyId());
    assertEquals("Activiti rocks", historicProperty1.getPropertyValue());
   …

ronnybr
Champ in-the-making
Champ in-the-making
Thank you for your answer. I found the problem.
I have been using

runtimeService.startProcessInstanceByKey("key", processVariables);
to start the process and expected it to work like

formService.submitStartFormData(definition.getId(), processVariables);
So I changed that method call, when trying to start the process, and now everything works just fine.