How can I use an object (POJO) on Forms?

Hello,
In a service task, I’ve set a serializable POJO (with getters and setters) into the process variables and named it as request.

execution.setVariable("request", releaseRequest);

In the next human task, I tried to use this object into a form created by Camunda Modeler using something like this ${request.releaseMethod}, but I’m receiving a message “Form failure” in the task list.

I would like to show the already computed values that is on some of this object’s fields (as read only) and edit some others. Is there a way to do that ?

thanks

Hi,
I would input-output mappings on the user task:

  1. I’d use an input mapping to create a local variable for each attribute of the POJO that I’d like to view/edit.
  2. I’d change the form to show these variables rather than the POJO
  3. If we allow edits, I’d add an output mapping that updates the POJO variable based on the values.

Consider the following example process and form:
process.bpmn (3.8 KB)
form.form (524 Bytes)

The service task creates a variable of the following POJO:

package org.camunda.forum;

import java.io.Serializable;

public class Request implements Serializable {

  private String requester;
  private String request;

  public String getRequester() {
    return requester;
  }

  public void setRequester(String requester) {
    this.requester = requester;
  }

  public String getRequest() {
    return request;
  }

  public void setRequest(String request) {
    this.request = request;
  }
}

For the user task, I configured the input and output mappings:

3 Likes

Thanks @StephanHaarmann