Input forms

Input forms

An important part of the module, Webforms are the input forms. The input forms are used by the Enrich by input form workflow component to change the contents of an XML file via an interactive form.

The input forms is a special kind of template in InterFormNG2. The forms are to be saved in the templates folder of the Library. The contents of the input forms is in JSON format and are to be saved with the extension, .frm.

Currently there is no editor for these input forms, so these have to be hand-written.

Attached is an example of a form that uses most of the available features (simple.json). 

The screenshot below is what the form looks like.

Basic template struture

The basic structure of a form template is as follows:
{
  "version": "1.0",
  "title": "Title",
  "requireClaim": true,
  "column": [ ]
}

“title” is the title text that is normally displayed above the form.
”requireClaim” indicates if the user must claim the form before editing the values. This field is optional (default false).
”column” is an array of all the fields in the form.

A minimal form with one field could look like this:

{
  "version": "1.0",
  "title": "Title",
  "column": [
  {
   "id": "customerNumber",
   "type": "number",
   "label": "Customer number",
   "path": "/root/header/customerNumber",
   "required": true
  }
  ]
}

It is possible to use a number of different field types in the form: Text input, numeric input, selection drop-down, resource selection browser and checkbox.
It is also possible to place up to 3 fields in the same row by using the “row” field type.
For all types (except row), a number of common mandatory fields must always be present:

Name
Type
Description
id
string
A unique (within this form) field id.
type
string
The field type. Valid values are:
text, number, select, checkbox, row
label
string
The label text that is displayed for this field.
path
string
The path within the XML of the element that holds/should hold this value.
This is written in XPath notation, e.g. /root/header/customerNumber
For elements within arrays, an attribute must always be used to indicate the exact element within the array, e.g. /root/body/product[@index='1']/name
Since this is a JSON file, the attribute should be in single quotes instead of double quotes.

For the row type, only the id and type are mandatory, label and path are not used.

The additional JSON fields for each type of form field are described in details below.
Row layout (type: “row”)
By default all fields are placed in a column. Using the “row” type it is possible to place 2-3 fields in a row.

Name
Type
Description
row
JSON array
An array of 2-3 regular fields

Text input (type: “text”)
The text field lets the user enter a text string.

Name
Type
Description
required
boolean
If the form field must have a value before the form can be submitted.
readOnly
boolean
If the field should be read-only (not editable in the form).
tooltip
string
A helpful tooltip to display on the form field.
multiline
boolean
If the field should allow multiple lines of text.
validation
JSON object
Validation rules, see below.

Validation rules object:
Name
Type
Description
min
integer number
Minimum number of characters.
max
integer number
Maximum number of characters.
pattern
string
Regular expression in Javascript format (same as Java really). The input is valid if it matches the regular expression.
Test it for instance on https://regex101.com


Numeric input (type: “number”)
The number field lets the user enter a numeric value.

Name
Type
Description
required
boolean
If the form field must have a value before the form can be submitted.
readOnly
boolean
If the field should be read-only (not editable in the form).
tooltip
string
A helpful tooltip to display on the form field.
validation
JSON object
Validation rules, see below.

Validation rules object:
Name
Type
Description
min
integer number
Minimum value.
max
integer number
Maximum value.


Checkbox (type: “checkbox”)
The checkbox displays a boolean value as a checkbox, where true = checked.

Name
Type
Description
readOnly
boolean
If the field should be read-only (not editable in the form).
tooltip
string
A helpful tooltip to display on the form field.

Drop-down (type: “select”)
The drop-down displays a set of values from which the user can select one.
The values can be specified in the template, or fetched from NG2 (the same value sets as are available in the workflow components).

Name
Type
Description
required
boolean
If the form field must have a value before the form can be submitted.
readOnly
boolean
If the field should be read-only (not editable in the form).
tooltip
string
A helpful tooltip to display on the form field.
options
Array of string
The list of values to display in the drop-down. This should only be used for a fixed set of values.
Example: ["Denmark", "Finland", "Norway", "Sweden"]
optionsRef
string
ID of the NG2 value list to display. Example: “CHAR_ENCODING"
The names of all available lists can be found from:
https://localhost:8086/rest/forms/getFieldOptions
(where localhost is to be replaced with the IP-address or host name of the InterFormNG2 server).
optionsPath
string
Path within XML to an array containing the values for the drop-down.
The elements in the array must have an attribute with a unique value.
optionsKeyAttr
string
When using optionsPath, this should be the name of the attribute that is used as index in the array. The value of this attribute is used to indicate the selected element in the drop-down.

Note that “options”, “optionsRef” and optionsPath are mutually exclusive. Only one of them should be used.

Resource selection (type: “select”)
This field lets the user select a resource from a library. Clicking the field opens a file browser.

Name
Type
Description
required
boolean
If the form field must have a value before the form can be submitted.
readOnly
boolean
If the field should be read-only (not editable in the form).
tooltip
string
A helpful tooltip to display on the form field.
optionsResource
string
The library to display resources from.
Valid values: templates, translations, images, fonts, documents, mailTemplates, templateComponents, styles, others
resourceFolder
string
Optional default folder in which the browser should open.


 


 





    • Related Articles

    • Enrich by input form

      The advanced, special workflow component, Enrich by input form is a workflow component, that can help to modify the XML payload of a workflow with a webform. Please notice, that an alternative webform solution is covered in the section, Webforms. ...
    • Email input

      This section describes the various email inputs. Email input covers both the various payloads, that you can use when emailing, but it also includes the option to setup a workflow to monitor an email account for incoming emails. 1. Use an XML file or ...
    • M3 input

      InterFormNG2 can with the M3 module be setup to process files directly from InterFormNG2. This is covered in the section, Infor M3 integration. After both Infor M3 and InterFormNG2 has been configured, the next thing is to setup InterFormNG2 to ...
    • Workflow input types

      The workflows of InterFormNG2 can get the input from various input types. In the workflow the input type is shown as the leftmost (green) component: The input types are all listed here: AS400 Command input Call InterFormNG2 via a command on the IBM i ...
    • Splitting input files

      InterFormNG2 is able to split up these types of files: Spooled files XML files If the input file is of any other type e.g. CSV or JSON, then you need to convert the input file into XML (with CSV to XML or JSON to XML) before you can split it up. When ...