Processes

[jBPM] Form Modeler

jBPM Version by the time of this writing: 7.32.0

1. What is it?

Business Central have an easy-to-use, yet advanced, feature to help building forms for processes, cases and human tasks. Based on the process/task variable types, it can infer the correct HTML component to be used for a specific situation.

So let’s say your process contains a variable that should store LocalDateTime values, jBPM automatically adds a datetime picker in your form!

And it goes even further: it can properly work with file upload components, checkboxes, lists, complex objects (POJOs), combo box, HTML code and more.

2. Why use it?

These forms can be helpful on the following scenarios:

  • It can be used during the process authoring within business central, to validate the process, case or rules you are working at;
  • It can be embedded in external applications as-is using PatternFly;
  • It can be consumed and rendered in custom applications using your own customized renderer.
  • Your forms are deployed along with your processes/cases, so you can make sure they are always synchronized with the business needs;

Based on these scenarios, here are some first steps for your to start learning about the form modeler.

3. Tips on Form Modelling and Consuming

3.1. Modeling Forms

Import this basic sample forms project to check some of the capabilities of the form modeler.

Starting the process opens this form to request initial information to the user.

Both process and task forms were automatically generated based on the process and task variables. They have some slight modifications which I did to demonstrate some additional features.

When you use Complex Objects, like POJOs, jBPM form modeler will treat them as nested forms. Notice in the first image with the form editor below: the process form includes the nested form “Nested Form of My Object“:

Form Modeler: Process Form

While the Complex Object “MyObject” owns a form that can handle all it’s attributes and can be included in other forms as well:

Form Modeler: Nested Form for a Complex Object.

For more details check the jBPM Docs Forms Section or import the sample displayed above to check the implementation details.

3.2. Working with Documents

The Form Modeler supports single file upload or multiple file uploads. In order to implement that in your business projects, there are some things you should remember:

  • The process variable that will hold a single file, should be configured with type org.jbpm.document.Document. The form modeler will generate a single file upload for this document:
Single file upload
  • The process variable that will hold multiple files, should be configured with type org.jbpm.document.DocumentCollection. The form modeler will allow the user to drag and drop multiple files:
Multiple Files Upload
Multiple Files Uploaded

Important: in order to use documents in process or case projects, you must add a DocumentMarshaller strategy (default one or custom ones). In this example we configured the following marshaller to handle multiple docs:

name: new org.jbpm.document.marshalling.DocumentCollectionImplMarshallingStrategy(new org.jbpm.document.marshalling.DocumentMarshallingStrategy())
resolver: MVEL

Check the deployment descriptor configuration within business central interface:

Marshalling Strategy Configuration

3.3. Consuming Forms

This is a brief of how you can get started consuming your forms. For a start, check /kie-server/docs/ for the available form APIs.

Notice there are three types of forms (processes, tasks and cases), and for each form you can choose a fragment of code or a rendered form. Check the rendered content of the sample form when accessing the following URL:

http://localhost:8080/kie-server/services/rest/server/containers/forms-sample/forms/processes/forms-sample.ProcessSample/content

Form request directly to the engine.

Finally, if you want to customize the form, besides using a custom renderer, you can also invoke the URL like the one below (without /content). You should get a formatted html text which you can customize:

http://localhost:8080/kie-server/services/rest/server/containers/forms-sample/forms/processes/forms-sample.ProcessSample


Conclusion

The jBPM Documentation form section provides more details on how to create a form from scratch, how to use the different types and customizations like read only formats, etc…

You can also refer to these Maciej Swiderski’s posts:

Hope this gives you some introductory information on you how can use form modeler to help building your business apps! 🙂

Leave a comment