Skip to main content
Version: 2027 R1

Form rules

Form rules are a visual mechanism for controlling the behavior and appearance of a form, designed as an alternative to JavaScript scripts. They make it easy to define dependencies between form fields – e.g. hide and show fields, mark them as required, set their values, block editing or change the appearance of controls – and keep the conditions that control the form in one place.

Form rules are executed in the user's browser, e.g. when the form page is loaded or after a form field value changes. A rule defined once can be reused in many places of the configuration. When a rule needs to be changed, it is enough to modify it where it is defined – the change is applied everywhere the rule is used.

Where rules are defined​

Form rules can be defined on two levels:

  • globally – in the Global definitions section – the rules are available in all processes,
  • in a process – in the Definitions node of the selected process – the rules are available only within that process.

Global rules​

To open the list of global form rules, select the Global definitions section on the icon bar of the side panel, and then select Form rules. A new rule is added with the Add global form rule button.

List of global form rules in the Global definitions section

Rules created in Legacy Designer Studio whose configuration cannot yet be edited in Designer Studio are marked on the list with a warning icon. Hovering over the icon displays the message Configuration available only in Legacy Designer Studio – such a rule can be viewed and edited only in the Legacy Designer Studio application. From Designer Studio you can still check where the rule is used and delete it.

Process rules​

To open the list of form rules of a process, expand the process in the application tree, select the Definitions node (or the Definitions tab in the process view), and then select Form rules. The number of rules defined in the process is displayed next to the Form rules item. A new rule is added with the Add form rule button.

List of process form rules with the rule menu and the Move to group submenu expanded

Rule list​

The form rule list looks the same at the global level and at the process level. The following elements are available above the list:

ElementDescription
SearchFilters the list of rules by name.
Add form rule / Add global form ruleCreates a new rule and opens it in the rule editor.
Add groupCreates a new group of rules (see Rule groups).

The list contains the Name and Documentation columns – the second column presents the description entered in the Documentation field of the rule configuration. Rules and groups that contain unpublished changes are marked with a blue dot.

Clicking a rule row opens the Rule configuration panel on the right side of the screen, and the Open configuration in full view icon Open configuration in full view icon next to the rule name opens the rule editor. The rule row menu (⋮ icon) contains the following commands:

CommandDescription
Open configuration in full viewOpens the rule in the rule editor.
Open configuration in the side panelOpens the Rule configuration panel with the rule name, documentation and edit mode.
Show usagesDisplays the list of configuration places where the rule is used.
Add form ruleAdds a new form rule (at the global level: Add global form rule).
Move to groupMoves the rule to the selected group. The <No group> option takes the rule out of its group. The command is available when at least one group exists on the list.
Delete form ruleDeletes the rule.

Rule groups​

Form rules can be grouped to make them easier to manage when there are many definitions. To create a group, click the Add group button – a new group appears on the list, and a panel opens on the right where you can rename the group (by clicking its name) and enter its description.

To put a rule in a group, select Move to group from the rule menu and choose the group. A new rule can be created directly in a group with the Add form rule command from the group menu. The group menu also contains the Open configuration in the side panel and Delete group commands.

Rules that belong to a group are displayed on the list nested under its name. Groups are also visible in the tree of the Functions tab in rule editors and in the path above the rule editing area.

Rule editor​

Form rules are built in the rule editor – the same one that is used, among others, to define business rules and conditions in form field configuration. The editor opens in the Designer Studio workspace after adding a new rule or after selecting the Open configuration in full view command. The path above the editing area indicates the edited rule (e.g. Comments › Form rule: Hide comments on a mobile device), and the side panel on the right contains the elements that can be inserted into the rule.

Form rule editor with a sample IF THEN ELSE rule and the side panel on the Values tab

Building a rule​

A rule is built from blocks – operations, functions, variables and values. To insert an element, click a place in the editing area, and then double-click the element in the side panel or drag it to the editing area. As indicated by the hint displayed in the empty editing area, Ctrl + Space displays a list of suggestions, and typing @ lets you search for objects.

Functions that require arguments are inserted together with empty argument placeholders. For example, the IF THEN function from the Conditional choice group inserts the IF, THEN and ELSE blocks – in the condition placeholder you can insert e.g. the Is this a mobile device? variable, and in the THEN and ELSE sections the HIDE COMMENT and SHOW COMMENT functions. Each rule row has the Move row up, Move row down, Add row and Remove row buttons, which let you change the order of instructions and add or remove instructions.

Variables inserted into a rule are displayed as colored blocks. A detailed description of variables and their appearance can be found in the Variables chapter.

The editor also provides:

  • the Close the side panel button in the upper right corner of the editing area (with a corresponding button to reopen the panel),
  • the Configuration button – opens the Rule configuration panel,
  • the Testing button in the lower left corner – displays a bar where you can enter the ID of a workflow instance and display a Preview of the rule in the context of that instance,
  • the Fit to screen, Zoom out and Zoom in buttons in the lower right corner – let you control the zoom level of the editing area. The zoom can also be adjusted with the Ctrl + Scroll keyboard shortcut.

Side panel​

The elements that can be inserted into a rule are grouped on the tabs of the side panel. A Search field is available above the element tree.

TabContent
OperationsArithmetic operations, logical operations and comparisons.
FunctionsProcess business rules and process form rules, global business rules and global form rules, and built-in functions, including functions specific to form rules (see Form rule functions).
ValuesVariables – system fields, form fields, global and process constants, context variables and performance indicators.
ObjectsIdentifiers of configuration objects, e.g. form fields, steps or paths.
Functions tab of the side panel with the list of function groups

The Functions tab lets you use other, previously defined rules in a rule – just expand the Process form rules or Global form rules group and insert the selected rule. This way complex logic can be defined once and called in many places.

In form rules, the Context variables group on the Values tab contains items related to the context in which the form is displayed:

VariableDescription
Current userInformation about the logged-in user, available in several variants (e.g. login, name, language).
Is admin mode active?Returns whether the form is displayed in admin mode.
Is edit mode active?Returns whether the form is displayed in edit mode.
Do I have permission to edit?Returns whether the user has permission to edit the instance.
Is this a mobile device?Returns whether the form is displayed on a mobile device.
Is this a compact form?Returns whether the form is displayed in compact mode.
Is this a new instance?Returns whether the workflow instance has not been saved yet.

Rule configuration​

The Rule configuration panel opens with the Configuration button in the rule editor or with the Open configuration in the side panel command from the rule menu on the list.

Rule configuration panel with the Documentation and Edit mode fields

The panel header displays the rule name – clicking the name lets you change it, and the Translations button lets you define its translations. Below are the rule GUID (the Copy content to the clipboard button copies its full value) and the Show usages button. The Basic tab contains the following fields:

FieldDescription
DocumentationDescription of the rule displayed in the Documentation column of the rule list. Supports translations.
Edit modeThe way the rule is defined (see the table below).
Edit modeDescription
Form ruleThe rule is built from blocks in the visual editor. Default mode.
JavaScript modeThe rule is defined as a JavaScript script. In this mode the Operations tab is not available in the side panel, and inserted elements are presented in the JavaScript format. The mode is described in detail in the JavaScript in WEBCON chapter.
caution

The Form rule and JavaScript mode edit modes work independently – changing the mode does not transform the existing expression but clears the current content of the rule. If the mode was changed by mistake, the rule content can be restored with the Undo last action button on the top bar of Designer Studio.

Using form rules​

Form rules are executed when the form page is loaded or after a form field value changes. They are triggered in the workflow form configuration and in form field configuration – in each of these places you can build a rule directly or insert a previously defined process rule or global rule into it.

Rule executed on page load​

The rule executed when the form is opened is defined in the Form configuration panel, which opens with the Configuration button in the upper right corner of the form designer (the Form tab of the workflow). The Behavior tab contains the following options:

OptionDescription
Form rule executed on page loadWhen enabled, lets you define a rule executed every time the form page is loaded.
Separate formulas for the compact formWhen enabled, lets you define a separate rule executed when the form is loaded in compact mode.
Behavior tab in the Form configuration panel with the form rule executed on page load enabled

When the option is enabled, the Enter a rule field is displayed. The Open the expression editor button in the upper right corner of the field opens the rule editor – the path above the editing area then indicates the workflow, the form and the edited option. In the example below, a previously defined process rule, selected from the Comments group on the Functions tab, has been inserted into the rule. The inserted rule is presented as a block with its name and a green badge.

Editor of the form rule executed on page load with an inserted process rule

Rules in form field configuration​

Rules that control the behavior of individual form fields are defined in the Form field configuration panel, on the Conditions tab. The panel opens after clicking a form field in the form designer.

Conditions tab in the Form field configuration panel
SectionOptionDescription
Default valuesection switchLets you define a rule that determines the default value of the form field.
Set when refreshing default valuesSets the default value again when another form field forces a refresh of default values (has the Value change will cause default values to be refreshed option enabled). The default value is set only if the field previously had no value and was configured in the Form Field Matrix as editable or Read-only (editable via form rules).
Value changeRun a rule after value changeLets you define a form rule executed after every change of the form field value.
Value change will cause default values to be refreshedChanging the value of this form field triggers a recalculation of default values for all fields that have the Set when refreshing default values option enabled.
VisibilityVisibility on form controlled by a ruleWhen disabled, the field's visibility follows the Field Matrix settings. When enabled, the field is visible if the rule returns POSITIVE, TRUE or 1; any other value hides the field. The rule is only taken into account when the field is marked as visible in the Field Matrix.
Custom visibility on reportsLets you define a list of people for whom the field will be visible on reports. If this option is disabled while Visibility on form controlled by a rule is enabled, the field will not be visible on the report.
Index in SOLR regardless of visibility rulesValues of fields with a visibility rule are not added to the SOLR index by default. Enabling the option adds them to the index on every modification, so they are included in quick search. Archival and technical fields are never indexed.
Always show in instance historyThe field is always shown in the instance history (the visibility rule is ignored). If the option is disabled and a visibility rule is defined, the field is always hidden in the instance history.
Never show in e-mail notificationsThe field is not shown in e-mail notifications. If the option is disabled, the field's visibility in notifications depends on the visibility rule.
EditabilityEditability controlled by a ruleWhen disabled, the field's editability follows the Form Field Matrix. When enabled, the field is editable if the rule returns POSITIVE, TRUE or 1; otherwise it is set as Read-only (editable via form rules). The rule works only when the field is marked as editable in the Form Field Matrix.
RequirednessRequiredness controlled by a ruleWhen disabled, the field's requiredness follows the Field Matrix. When enabled, the field is required if the rule returns POSITIVE, TRUE or 1; any other value means the field is not required. The rule is only taken into account when the field is marked as required in the Field Matrix.

Execution order​

Form rules executed on page load and on form field value change are run in a specific order, which depends on where they are defined:

  • Page load – the rule defined in the workflow form configuration (global form) is executed first, followed by the rule defined for the form on the step where the instance is located.
  • Value change – the rule defined in the form field configuration (the Run a rule after value change option) is executed. If a separate value-change rule is defined for this form field in the form configuration on a step, that rule is executed instead of the rule from the form field configuration.

Form rule functions​

The Functions tab of the side panel contains groups of built-in functions. Some of them – Conditional choice, Number, Text, Date and time, Element collections and Conversions – are shared with business rules. The functions related to the appearance and behavior of the form are presented below.

Behavior​

FunctionDescription
SETSets the form field on the form to the specified value.
SET FOCUSPlaces the cursor in the specified form field after the form is loaded or after a field value changes.
HIDEHides a form field that is visible on the form.
SHOWShows a form field previously hidden with the HIDE function.
HIDE COMMENTHides the comments control together with all its entries.
SHOW COMMENTShows the comments control together with all its entries.
HIDE OCR TRAIN BUTTONSHides all OCR training buttons visible on the form.
SHOW OCR TRAIN BUTTONSShows the OCR training buttons previously hidden with the HIDE OCR TRAIN BUTTONS function.
SCAN QRActivates the QR code scanner for the specified form field or column. Can be executed on form page load or after a form field value changes.
SHOW QRDisplays a button in the form field or column control that lets you scan a QR code and insert its value. For Item list columns, the effect can be narrowed down with FOR EACH ROW.
HIDE QRHides the QR code scanning button in the form field or column control. For Item list columns, the effect can be narrowed down with FOR EACH ROW.
DISABLEPrevents entering and editing the form field value on the form. The value can still be changed with JavaScript.
ENABLEUnblocks editing of a form field previously blocked with the DISABLE function.
MARK REQUIREDMarks the specified form field as required.
MARK NOT REQUIREDMarks the form field as not required. Works only on fields previously marked as required with the MARK REQUIRED function.
ALERTDisplays a dialog box with the specified text and an OK button over the form.
CONFIRMDisplays a dialog box with the specified text and the OK and CANCEL buttons over the form.
SET FORM TITLEReplaces the text displayed in place of the instance signature and in the browser tab or window title.
SET FORM SUBTITLESets a subtitle in the form banner.
HIDE PATHHides a path visible on the form.
SHOW PATHShows a path previously hidden with the HIDE PATH function.
MOVE TO NEXT STEPMoves the instance to the next step using the specified path.
HIDE MENU BUTTONHides the specified menu button.
SHOW MENU BUTTONShows a menu button previously hidden with the HIDE MENU BUTTON function.
INVOKE MENU ACTIONSimulates a click on the specified menu button.
EXPANDExpands the specified group of form fields.
COLLAPSECollapses the specified group of form fields.
SELECT TABSets the specified tab as the currently visible tab of the tab panel.

Item list​

FunctionDescription
GET ROW VALUEReturns the value from the specified column of the Item list row currently being edited.
SET ROW VALUESets the specified value in the specified column of the Item list row currently being edited.
INITIALIZERefills the Item list with the values defined in its form field configuration.
ADD NEW ROWAdds a new row to the specified Item list. The cells of the new row are filled with default values.
DELETE ALL ROWSDeletes all rows of the specified Item list.
HAS ANY ROWSReturns TRUE if the specified Item list has at least one row.
ITEM LIST COUNTReturns the number of rows of the specified Item list.
SELECT VALUESReturns all values from the specified Item list column as a collection of elements.
IS NEW ROWReturns whether the given row has not been saved yet.
FOR EACH ROWExecutes a block of operations for every row of the specified Item list.
MARK REQUIREDMarks the specified Item list column as required.
MARK NOT REQUIREDMarks the specified Item list column as not required. Works only on columns previously marked as required with the MARK REQUIRED function.
HIDE ITEM LIST COLUMNHides an Item list column visible on the form.
SHOW ITEM LIST COLUMNShows an Item list column previously hidden with the HIDE ITEM LIST COLUMN function.
HIDE ITEM LIST ROW BUTTONHides the selected action button in an Item list row.
SHOW ITEM LIST ROW BUTTONShows the selected action button in an Item list row.
HIDE ITEM LIST BUTTONHides the selected Item list button.
SHOW ITEM LIST BUTTONShows the selected Item list button.

Item list styling​

FunctionDescription
SET CELL FONT COLORSets the font color of an Item list cell.
SET CELL FONT DECORATIONSets the font style of an Item list cell.
SET CELL FONT SIZESets the font size of an Item list cell.
SET CELL FONT FAMILYSets the font family of an Item list cell.
SET CELL BACKGROUNDSets the background color of an Item list cell.
SET CELL STYLESets the CSS style of an Item list cell.

Attachments​

FunctionDescription
ATTACHMENT EXISTSChecks whether there is an attachment whose name, including the extension, matches the criterion specified as a regular expression.

Field styling​

FunctionDescription
SET CONTROL FONT COLORSets the font color of the form field value.
SET CONTROL FONT DECORATIONSets the font style of the form field value.
SET CONTROL FONT SIZESets the font size of the form field value.
SET CONTROL FONT FAMILYSets the font family of the form field value.
SET CONTROL BACKGROUNDSets the background color of the form field control.
SET CONTROL STYLESets the CSS style of the form field control.
SET LABEL FONT COLORSets the font color of the form field name.
SET LABEL FONT DECORATIONSets the font style of the form field name.
SET LABEL FONT SIZESets the font size of the form field name.
SET LABEL FONT FAMILYSets the font family of the form field name.
SET LABEL BACKGROUNDSets the background color of the form field name.
SET LABEL STYLESets the CSS style of the form field name.

oAuth​

FunctionDescription
AUTHENTICATEAuthenticates the specified OAuth authentication form field.
IS AUTHENTICATEDChecks whether the specified OAuth authentication form field has been authenticated.

Location​

FunctionDescription
CURRENT LOCATIONReturns the user's current GPS location. Retrieving the location requires the user's consent. If the location is not available or the user has not given consent, the EMPTY value is returned.
info

Additional information on form rules can be found on the technical blog in the following articles: