PAK Commands – Create Form
1. Summary
This command lets you create a multi form page which the user has to fill out to continue.
2. Examples
Due to simplicity, the descriptiveText
input parameter will be left empty for the examples. By default, it is set to „Please fill out the form below to continue“.
All example images use the Human Task representation of the Workflow Executor. |
The labelList
input parameter is required and represents each input which will be a text field by default.
2.1. Minimal Command Run
|
|
In the first example we ran the command with the labelList "First Name, Last Name, Email"
. By default, all inputs will be text field and every input is mandatory. When the user for example fills the form with John
, Doe
and john@doe.com
, the formObject
will be written as {"First Name":"John","Last Name":"Doe","Email":"john@doe.com"}
.
2.2. Adding Optional Fields
Sometimes not all fields have to be required, to exclude certain fields we can make use of the mandatoryFields
parameter, which accepts a list of boolean values.
|
|
In this example, we made the Email-field optional, this can be done by providing mandatoryFields
with "true, true, false"
, indicating that the first two inputs shall be mandatory, the last one however will be optional. The result can now either be the same as above, or {"First Name":"John","Last Name":"Doe","Email":null}
.
2.3. Adding Different Input Types
Only having text inputs will not fit our long-term needs, if we want to include some kind of date, for example the date of expiry, we can use the dataTypes
parameter. All available types are Text
, Date
and Number
.
|
|
In the third example, we substituted Email
with Date of Expiry
in the label list. To make the input a date chooser we can set dataTypes
to "Text, Text, Date"
. The result will now be written as {"First Name":"John","Last Name":"Doe","Date of Expiry":"2000-06-06T00:00:00.000Z"}
.
2.4. Setting initial Values
In the parameter initialValues a list of default values can be added to prefill the form. For the example above this parameter could be filled with "John,Doe,2000-06-06T00:00:00.000Z"
to produce following prefilled table.
2.5. Customizing the JSON Output
The last parameter we can make use of is the fieldIds
variable, which lets us choose the name of the inputs in the resulting JSON object. For instance, we might want to stay conformed to the Java variable naming syntax, so we can transform our JSON to a Java object. When we for example set fieldIds
to firstName, lastName, dateOfExpiry
, the resulting JSON object will be {"firstName":"John","lastName":"Doe","dateOfExpiry":"2000-06-06T00:00:00.000Z"}
.