There are different types of fields your form can be composed of. Depending on type, the enclosing element can be defined by its set of properties. We grouped them by the common porperties that they use.
Type | Description | Properties |
---|---|---|
text | Input field for alphanumeric strings. | plain fields |
number | Input field for numeric data. | plain fields |
boolean | Boolean field (true/false), by default rendered as checkbox. | plain fields |
table | Table element. | table |
textarea | Multiline input filed (beta version, limited) | textarea |
br | Single line break | line break |
hr | Horizontal line (ruler) | ruler |
h1-h6 | Heading, 1 - the biggest, 6 - the smallest | heading |
Note: if child elements are specified, the default type is: group otherwise text is assumed.
These fields consist of a label and data entry element (input/output box). They may be created by providing all required properties manually or by retrieving them from metadata. If metadata is used, then only the field Id is required. The rest of the properties, if not provided, will be taken from the specified metadata (or from the default metadata specified on the form’s level).
Property | Description | Example |
---|---|---|
id | Field id. If metadata for this element is defined and contains a field with this id then its definition will be used to create the field. | “id”: “orderNumber” |
text | The fields’s label. | “text”: “Order number” |
type | The type of the field. It is inferred from the referenced metadata if specified. Applicable types: text, number, boolean. | “type”: “number” |
length | The length of the field - the maximum number of characters that can be entered. | “length”: 15 |
scale | The number of decimal digits if the type is number. Default is 0 (integer). | “scale”: 2 |
metadata | The metadata (object/object.method name) that will serve as a source of properties for this and child elements. | “metadata”: “purchaseOrders” |
metadataField | The metadata field (object.method.field) that will serve as a source of properties. This way a field may be generated using properties from other field (not linked by field ID). | “metadataField”:“item.get.id” |
readonly | Boolean. True makes the field an output field. Expression !!! DEFINE !!! may be used. Default is false. | “readonly”: true |
mandatory | Boolean. If set to true the field must not be empty when sending data otherwise en error will be shown. Default is false. | “mandatory”: true |
value | The default value that will be assigned to the field when created. The value should be of the same type as the destination field: string, number or boolean. Expression !!! DEFINE !!! may be used. | “value”:“batchItem ? 1 : 0” |
active | Boolean. This property controls whether the field should be active. None active fields exist on forms but are hidden. Expression !!! DEFINE !!! may be used. | “active”:“balance > 0” |
focus | Boolean. When true the field will get focus when the form is opened. To set focus dynamically, see actions (focus instruction). | “focus”: true |
cache | Boolean. When true, the field will cache its latest value for the whole session. This attribute may be usesful in e.g. selection fields to remember the selection. The cached value has lower priority then values coming from other source like: set instructions, method response etc. | “cache”:true |
allowBlank | Boolean. Used when calling APIs. This property controls how to react when the field has no value. When allowBlank is true then empty string will be sent. When false and the field is mandatory then en error is shown, otherwise the field is ignored (optional). Default is false. | “allowBlank”:true |
Note: Some of metadata properties may be overriden: text, readonly, active, mandatory.
A form with several fields:
{
"text": "Metadata",
"onLoad": { "method": "apiMetadataInfo.get" },
"metadata": "apiMetadataInfo.get",
"elements": [
{ "id": "id", "readonly": true },
{ "id": "version", "readonly": true },
{ "id": "apiFrameworkVersion", "readonly": true },
{ "type": "br" },
{ "type": "h4", "text": "Methods" },
{ "id": "apiMethod", "metadata": "apiMethod.get", "cache": true },
{ "id": "sequence", "type": "number", "text": "Sequence", "length": 2 }
],
"actions": [ "*close" ]
}
Table element is described by a set of columns which may be provided as child elements. When metadata is provided the column set will be retrieved from referenced array element of the metadata - then there is no need to specify elements.
It is possible to display a subset of columns from metadata by either:
Property | Description | Example |
---|---|---|
elements | The list of column elements, may be retrieved from metadata. | “elements”: [col1,col2] |
direct | Boolean. When true it enables the single click selection - clicking/tappin a row runs directly the default action. Default is false - the clicked row is marked/unmarked (highlighted). | “direct”: true |
exclude | The list of column names that will not be created in the table. It may be usefull when metadata contains more columns than we want to display. | “exclude”: [“debtor”, “handler”] |
actions | The list of table action elements. The actions will be accessible as the table’s context menu. | “actions”: [action1,action2] |
Table columns are defined in the same way as plain fields.
A list of actions may be specified for a table. The actions will be accessible as table’s context menu - by right mouse-click or tap-and-hold on mobile devices. Then, the popup menu will be displayed with all table actions. The actions may be run in connection with selected table items therefore there are a few special propertied to be used in actions to be able to operate on the selected table data.
To refer to data from selected items, use prefix ‘#’ for field name (column name). For example, “#orderNumber” - refers to the order number from the selected table row.
When an action is intended to run with one selected item only, use a single item table action, directly refering to the selected item (if multiple items are selected, the first one is processed).
Example of a table action with single item reference:
{
"text": "Details",
"form": "methodDetails",
"params": { "apiMethod": "#apiMethod" }
}
In this example, when table option Details is chosen, the form methodDetails will be displayd. The value for form’s input parameter apiMethod will be taken from the selected table row and column of the same name apiMethod.
When an action is intended to be run for all selected items, another type of action may be used: forEach. The action will iterate over all selected items and and run specified inner action.
Example of a table action with multi item processing:
{
"text": "Delete",
"forEach": {
"method": "salesOrder.delete",
"params": { "orderNumber": "#orderNumber" }
},
"onOK": {
"form": "salesOrders"
}
}
Here is en example with a form that contains:
{
"text": "Metadata",
"onLoad": { "method": "apiMethods.get" },
"metadata": "apiMetadataInfo.get",
"elements": [
{ "id": "items", "metadata": "apiMethods.get",
"elements": [
{ "id": "apiMethod", "text": "Name" },
{ "id": "description" }
],
"actions": [
{
"text": "Details",
"form": "methodDetails",
"params": { "apiMethod": "#apiMethod" }
}
]
}
],
"actions": [ "*close" ]
}
This is a multi line output field. It accepts array as data source. The lines are collected from the array using field name provided in data-stc property.
Example of text lines for Sales orders. If the response contains the following data:
{ "items": [ { "text": "Text notes 1"}, { "text": "Text notes 2"} ] }
The correspnding textarea element will be specified like this:
{ "id": "items", "type": "textarea", "text": "Sales order text", "data-src": "text", "readonly": true }
where data-src refers to text field of the array the strings will be loaded from.
With this element you can add a line break - space between fields to separate them visually. Example with elements containg br element:
[
{ "id": "id", "readonly": true },
{ "type": "br" },
{ "id": "version", "readonly": true }
]
This element is similar to br - it separate fields with a horizontal line. Example with elements containg hr element:
[
{ "id": "id", "readonly": true },
{ "type": "hr" },
{ "id": "version", "readonly": true }
]
With this h(size) element you can place several different headings on your form. Example:
[
{ "type": "h6", "text": "Heading size 6" },
{ "type": "h5", "text": "Heading size 5" },
{ "type": "h4", "text": "Heading size 4" },
{ "type": "h3", "text": "Heading size 3" },
{ "type": "h2", "text": "Heading size 2" },
{ "type": "h1", "text": "Heading size 1" }
]