Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-9666

Field is not populated after it is added in Data Object

XMLWordPrintable

    • False
    • False
    • NEW
    • NEW
    • Undefined
    • Hide

      1. Create a Data Object with one field, type doesn't matter, String is enough. Override the toString() method to include this new field and save it.
      2. Create a process with Start Node -> Human Task -> End Node.
      3. Define one process variable with the type of the Data Object from the first step.
      4. Configure Human Task Input and Output variables, both with the same name, which will reference the process variable as source and target. So the Human Task will act as a way to read and modify the data object process variable using a form. Assing this task to yourself (e.g. wbadmin user).
      5. Save the process instance and generate all forms.
      6. Deploy the process and run a new instance of it. The starting process form should have one field, provide something as a value.
      7. Go to Task Inbox, start the task assigned to you, verify that the value is there, you can modify it. Complete the task.
      8. Process is finished. The process variables log correctly shows the object's field value history.
      9. Now go back, add one more field to the data object and include this data object in the toString() method. Save the data object.
      10. Delete all the forms (there should be 3 of them).
      11. Open the process definition and regenerate the forms.
      12. Redeploy the project.
      13. Run the process instance. Now 2 fields should be presented in the initial form. Fill both of them.
      14. Go again to Task Inbox and start the task. Now the newly added field does not have the value from the previous step. Just the first field should be populated.
      15. Populate also this second empty field and complete the task.
      16. The process should be finished. Now go to the process variables log and open the history of the variable. You will notice 2 things:
      a) the second field is still null, so neither of the forms actually set its value
      b) the "middle" value in the history shows the previous implementation of the toString() method.

      Show
      1. Create a Data Object with one field, type doesn't matter, String is enough. Override the toString() method to include this new field and save it. 2. Create a process with Start Node -> Human Task -> End Node. 3. Define one process variable with the type of the Data Object from the first step. 4. Configure Human Task Input and Output variables, both with the same name, which will reference the process variable as source and target. So the Human Task will act as a way to read and modify the data object process variable using a form. Assing this task to yourself (e.g. wbadmin user). 5. Save the process instance and generate all forms. 6. Deploy the process and run a new instance of it. The starting process form should have one field, provide something as a value. 7. Go to Task Inbox, start the task assigned to you, verify that the value is there, you can modify it. Complete the task. 8. Process is finished. The process variables log correctly shows the object's field value history. 9. Now go back, add one more field to the data object and include this data object in the toString() method. Save the data object. 10. Delete all the forms (there should be 3 of them). 11. Open the process definition and regenerate the forms. 12. Redeploy the project. 13. Run the process instance. Now 2 fields should be presented in the initial form. Fill both of them. 14. Go again to Task Inbox and start the task. Now the newly added field does not have the value from the previous step. Just the first field should be populated. 15. Populate also this second empty field and complete the task. 16. The process should be finished. Now go to the process variables log and open the history of the variable. You will notice 2 things: a) the second field is still null, so neither of the forms actually set its value b) the "middle" value in the history shows the previous implementation of the toString() method.

      I noticed that the data object field, which is added later after the initial deployment of the project, is not correctly "bound" to the forms, despite the forms are correctly configured. Previous fields are being correctly filled in, just the newly added field is not. See the enclosed screenshot.

      The second issue I noticed, which is related, is this:
      I tried to debug this a little bit using a custom toString() method on the data object, so I could see the process variable history log in the UI. When doing it, I noticed that the "middle" value is not executing the updated toString() method, it uses the "old" one, which is even more confusing. See the enclosed screenshot.

      So apparently after a new field is added to the data object, there are 2 issues observed:
      1. The forms are updated, so the new field is visible there, but after filling the new field the values is not propagated to the process instance.
      2. If I override the toString() method, it uses the old/previous implementation of it (with just one field) in the process variable log in the UI. So at some point the engine/workbench executes this method on the "old" version of the data object. I deliberately prepended the first toString() with Initial Impl string and then the second one, which also prints the second field, with Advanced Impl, so the difference is clearly seen.

      For the second part I added a few script tasks before and after the human task + I added onEntry and onExit actions to the human task which called just System.out.println(kcontext.getVariable("object").toString()); and here it always used the new up-to-date toString() implementation.

        1. ProcessStartForm.png
          25 kB
          Marian Macik
        2. TaskForm.png
          41 kB
          Marian Macik
        3. VariableHistory.png
          133 kB
          Marian Macik

              rh-ee-pefernan Pere Fernandez Perez
              mmacik@redhat.com Marian Macik
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: