My FNZ Studio Version

Business Objects

Latest Update: 13.11.2023 | Margherita Taffarel
Documentation
2022.2

Note that the Appway Platform has been renamed FNZ Studio (also referred to, generically, as Platform in this article). Appway Studio (design-time environment) and Appway Workspace (runtime environment) have been renamed FNZ Studio Composition and FNZ Studio Runtime, respectively. Refer to our Renaming article for full information.

1 Introduction

The Data Logic Business Object offers high-level abstraction through data and rule definition in the following ways:

  • It allows defining your business logic through a data- and rule-centric approach, simplifying implementation and removing the need for extensive scripting that other Solution design practices require. The Data Logic allows the developer to specify rules that apply certain constraints to the existing data model.
  • The UI is derived from the data model and is automatically generated, based on the definitions made in the Data Logic Business Object – a notion referred to as Auto-generated UI. This functionality is enabled, for example, by the Data Gathering App Task, a Data-Driven User Interface, which represents the first step in a progressive evolution of the Workspace into a fully Data-Driven approach. The automation of the UI accelerates development and minimizes effort regarding the visual presentation of your data and rule structure.

1.1 Examples of Data Logic and other Solution Design Approaches

The use of the Data Logic approach and other Solution design practices are not mutually exclusive, but can be combined. While practical business applications will normally prefer the Data Logic approach, more ad-hoc, manually built UIs using scripted business logic can be implemented in parallel. Following are some use cases:

  1. A Solution could have a form to enter Client information built with the Data Logic approach. The Data Logic Business Object is used to define the data points to be gathered and the validity constraints to be applied to such data points. The UI is fully auto-generated with no additional development effort and is integrated into the Solution a Data Gathering App Task. The same Solution could have a following step in the same Process where some documents and approvals are tracked through the Platform. This second step, not being data-centric, could be modeled using other (non-Data Logic) techniques such as Screen Components and scripted logic.
  2. Designing a form in the Platform using Screen Components, such as the Adaptive Flow Layout, requires a lot of manual effort and can result in slow UI performance depending on the additional logic you encode. For example, if you want to hide or disable part of a form based on the setting of a control, you have to add an Ajax Update Area, ensure everything is configured properly, and then you probably need to add a Screen Cache or Phase Control Screen Component to your Screen to make the interaction smooth.
    Instead of building the form manually and enforcing constraints by adding logic to hide/disable parts of the form, you can use a Data Logic Business Object. Here, you can define the content of your form and the data constraints (as Data Rules). This approach requires much less effort, is far less error-prone as the set-up is less complex, and the end result is faster for users.

2 Data Logic Business Object

The Data Logic Business Object allows configuring the Controls and Data Rules which define the desidered business logic around data. Controls represent the UI controls (input fields, checkboxes and so on) that are rendered in auto-generated UIs, while Data Rules represent the validation rules to be applied to data in order to ensure that it is business-compliant.

The Data Engine is the engine that processes the Data Logic Controls and Data Rules behind the scenes. The set of data that is processed according to the settings in the Data Logic is referred to as Data Context. The Data Context contains the value of the variables defined in the Data Logic.

Technical Notes on the Data Engine

Please, read the following list of technical recommendations carefully:

  • Named or Indexed Collections – Whenever the Data Engine encounters a Named or Indexed Collection that is null, it always initializes it to an empty collection in order to process it correctly. This changes the content of the Value Store containing the variables assigned to the Data Logic. Therefore, when using Data Logic functionalities, do not rely on the difference between null and empty collections for any business logic.
  • Data Context and Script Language – When using Data Logic, it is important that no changes are applied to the data contained in the Data Context using the Script Language, unless such changes are executed by the Update Function set on Primitive or Collection Controls. For example, Collection elements should never be added or removed in Scripts that are invoked by the Data Logic such as Sentries, bindings or Data Rule expressions; similarly, no property should be set or edited with such scripts. Follow this recommendation to avoid issues and unexpected behavior.
  • Data Context and Assigned Variables – All data that needs to be part of the Data Context must be assigned explicitly to the Data Logic using Assigned Variables. For example, Data Class instances that need to be part of the Data Context should not be loaded from a Database in Scripts that are invoked by the Data Logic: this loading logic should be executed outside of the Data Logic while initializing its Assigned Variables. Follow this recommendation to avoid issues and unexpected behavior.

Note on Terminology and Renaming

Some items in the Data Logic Business Objects have either been replaced, or renamed (and, in some cases, deprecated) since Appway 9. In the current article, such items are referred to with the latest terminology. Make reference to the attached Data Logic Renaming Table(PDF) in case of doubt.

Note that renaming has no functional impact.

3 Data Logic Editor Overview

DataLogicEditorOverview.png
The Data Logic Editor is composed of different areas:

  1. Header: The header background color indicates whether you are in edit mode (gray) or read-only mode (red). It allows performing various actions, including:
    • Edit Labels: Allows displaying an overview and further editing the Labels used in the current Business Object through the Translations tool.
    • Validate: Allows validating your edits on the Data Logic. The Validate icon is instantly updated upon your changes, thus providing immediate validation feedback (see Validation details below):
      • red: highlights an error, the Data Logic or part of it is invalid.
      • yellow: highlights a warning, the Data Logic is still valid but action is required.
      • green: the Data Logic is valid.
  2. Left sidebar: Contains Variables, Dependencies, and Validation information.
    • The Validation section contains validation messages for the current Data Logic. The Data Logic Editor supports instant validation: every time an action that triggers a validation issue is performed, the panel is updated with the corresponding information to allow quicker response. The Validation header indicates the total number of validation messages in the Data Logic. Types of message are:
      • Error: (red icon) the issue requires immediate action, and makes the Data Logic (or part of it) invalid.
      • Warning: (yellow icon) the issue requires immediate action, but the Data Logic can be still used to create a working Data Model.
      • Info: (gray icon) the issue does not require immediate action, but consider fixing it to have a Data Logic that complies with best practices.
    • The Dependencies section lists the Business Objects that depend (Used by section) on the current Data Logic and viceversa (Uses section). Dependencies are updated instantly whenever you perform any changes.
      Note that, starting from Appway 11, Label Business Objects are no longer shown as dependencies in the Data Logic Editor. You can see used Labels from the Translations tool (by clicking on the Edit Labels button on the header), and see Label dependencies from the Label Business Object library.
  3. Central area: Modeling area, containing the content of the Data Logic. The central area of the Data Logic Editor is composed of a filtering field, and four tabs:
    • Controls represent the UI controls (input fields, checkboxes and so on) that are rendered in auto-generated UIs. Controls can be moved on the editor by drag and drop. Multiselection is also available both for moving and deleting multiple Controls.
    • Data Rules define the Rules that data must fulfill to be business-compliant.
    • Collaboration (Legacy)
    • Variables
  4. Right sidebar: Library containing the items that can be added to the selected tab in the case of Controls and Data Rules.

3.1 Labels and Translations

The Data Logic Editor provides language and translation-related features in line with our effort toward Internationalization. Such features allow creating Label Business Objects on the fly for all text-related fields, as well as producing and storing translations for such texts.
In Platform versions previous to 10.1, the Data Logic Label and Extended Label fields were populated with static (untranslatable) Strings. With that approach, localizing the UI into another language implied changing the such texts one by one. Moreover, the developer was forced to unfold any folded Control to be able to translate texts.

3.1.1 Selecting a Label for Controls and Data Rules

Starting from Appway 10.1, instead, a Label Business Object selector is available for most text-related properties in Controls and Data Rules.

Important note: For existing Data Logic Business Objects, created before Appway 10.1.0, it is possible to migrate from the regular input field to the Business Object selector by replacing the content of the field with a Label Business Object Id (in the format [LABEL:myLabelId]).

Controls:

  • Label property – Can be displayed in the auto-generated UI to provide information for the end user. For Data Controls, this field is populated (where applicable) with a default label corresponding to the Data Class or property name, respectively:
    • Data Class: {PackageId}:aw.DataClass.{DataClassId}
    • Property: {PackageId}:aw.DataClass.{DataClassId}.{propertyName}
      The Label suggested by the system can be changed and a custom label can be selected. For other Controls, the Label property is empty by default.
      Note: Consider that, selecting a Label does not automatically create such Label in the system. For this reason, you may get a ‘missing dependency’ error when validating data. You actually create a Label in the system when translating it (see full information in the Translation Tool section below).
  • Extended Label property – Can be displayed in the auto-generated UI to provide additional information for the end user (e.g. a full sentence or a question). This property is optional and can be left empty.
  • Add Button Label – (only for Collection controls) Allows customizing the Label used in the Workspace for the button that allows adding an element to a collection of Data Class instances. The field is prefilled with the Label aw.DataLogic.addToCollection (available in the Base Package). Moreover, the Label already has the assigned variable elementTypeLabel.
  • Text property of the Text Control.

Data Rules:

  • Message property – This property cannot be left empty. For some Data Rules (Catalog Values, Mandatory Fields, Eligible Types), a default Label Business Object is selected. The Label suggested by the system can be changed with a custom label.
  • Type Selection Label property of the Eligible Types) Data Rule – This property cannot be left empty. A default Label Business Object is selected, but it can be changed with a custom label.

3.1.2 Creating a New Label and Defining Variable Assignments

The Label Business Object selector allows selecting an existing Label from the current or other Package. However, it also allows creating a new Label Business Object on the fly.

See full information in the Language, Labels and Translations article.

3.1.3 Using the Translations Tool

The Data Logic Editor allows displaying an overview and further editing the Labels used in the current Business Object through the Translations tool. Specifically, this tool allows:

  • Checking translated and untranslated Labels
  • Editing translations and variable assignments
  • Creating missing Label Business Objects
  • Generate English texts automatically for demo purposes

See full information in the Language, Labels and Translations article.

4 Controls Tab

The Controls tab allows defining Data Logic Controls. Data Logic Controls represent the UI controls (input fields, checkboxes and so on) that are rendered in auto-generated UIs, such as the ones generated through the Data Gathering App Task or the Interaction Channels. In addition, Data Logic Controls can be used to limit the user's course of action by defining Sentries (see details below).
To create a Data Logic Control, drag it into the Control area (from the Variables panel on the left or the Controls panel on the right).

Starting from version 2022.2, copy-paste options are available from the context menu for Controls (Copy Control, Paste Before, Paste After). These are also supported by shortcut keys.

DataLogicControls.png

Data Logic Controls are divided into two groups (see sections below for more details):

  1. Data Controls:
    • Primitive
    • Data Class
    • Collection
  2. General Controls:
    • End Task Action (Deprecated)
    • Start Subprocess Action (Deprecated)
    • Section Group
    • Field Set Group
    • Data Logic Include

Note on Data Classes used as bindings in Controls — Consider that only Data Classes with static functions used in scripts are replaceable. See the Replacing Business Objects section.

4.1 Control Properties – Note on Sentry

All Data Logic Controls share the Sentry property (accessed via the Properties icon: Properties icon).

Sentry defines the conditions which govern the state/availability of the Control for users in the auto-generated UI: enabled, disabled, hidden. The Sentry Example snippet can be used as a starting point when writing sentry expressions. Open the Script Editor for the sentry and select Snippet from the menu to access it.

Starting from version 2022.2, copy-paste options are available from the context menu for copying sentry values among Controls (Copy sentry, Paste sentry).

Moreover, consider the following additional information on the Sentry property:

  • The script defining conditions which govern the state/availability of the Control must resolve to one of the following three expressions:
    • DataLogicControl.SentryState.ENABLED() (default if no expression is defined for a top-level Sentry)
    • DataLogicControl.SentryState.DISABLED()
    • DataLogicControl.SentryState.HIDDEN()
  • Sentries set for parent Controls propagate to their children according to this logic:
    • If the Sentry setting for a child element is empty or returns null, or does not return anything, it inherits the setting of its direct parent.
    • If the parent is set to hidden, all child elements are hidden, regardless of their Sentry settings. This is the only scenario where the parent settings override the settings made for children, in all other situations the settings of the children are applied.

4.2 Data Controls

Data Controls are bound to variables and are used to specify the data that should be shown and/or edited in the UI. Data Controls can be created in two ways:

  • By dragging variables from the left side Variables panel to the Controls tab (valid locations for dropping are indicated by a blue background when hovering). The Binding field is set accordingly.
  • By dragging the according Control from the right side Data panel to create an Unnamed Control. Set the value for the Binding field manually by one of the following approaches:
    • Use the same syntax as for automatically generated Controls, e.g. $variable or $variable.property.
    • Use an arbitrary Script expression which returns the data point to be used as a binding. For example, the Script expression $client.addresses['secondary'] points to a specific element in a Collection.

Three Data Control types are available (see sections below):

  1. Primitive
  2. Data Class
  3. Collection

4.2.1 Primitive

Appearance of the Primitive Data Control visible on the Controls Tab.
A Primitive Control is created for single element variables which are Primitive Types.

  1. To create a Primitive Control, drag it from the Controls section in the right-side library.
  2. Set the binding (see binding details at the beginning of this section).
  3. Set the sentry (see the note on sentry for details).
  4. Set the Label and Extended Label properties (see the Labels and Translation) section for details).
  5. In the Update Function field, you can specify a logic to be executed when changes are made on the Control in the Workspace. Select a Script Function Business Object: this is executed when the value of the Control is updated in the Workspace. Consider the following information:
    • When an Update Function script changes a value on another field, the Update Function script is not executed on that field, meaning that each Update Function needs to be self-sufficient and execute all the necessary changes by itself.
    • The Update Function is executed even if there are validation messages on the field.
    • The Update Function must be simple and lightweight: heavy functions would have a highly negative impact on performance. Moreover, Integration Calls (Database queries, Web Services call and so on) should be avoided. In general, we recommend using this setting only when strictly necessary, so as not to affect Solution maintainability.
      The System Health Sensor Data Logic Update Function Execution Time checks the average execution time of Update Functions defined in Data Logic Business Objects to ensure optimal UX. See full information.

4.2.2 Data Class

Appearance of the Data Class Data Control visible on the Controls Tab
A Data Class Control governs the complete Data Class, e.g. if you define a Sentry, it is valid for the entire Data Class (all properties).

  1. To create a Data Class Control, drag it from the Controls section in the right-side library.
    You can open the selected Data Class by double-clicking on the Control, or by right-clicking on it and then selecting the Open Data Class button. Moreover, the context menu includes the Remove, Keep Children option, which allows removing the main Data Class control while keeping its children (if any).
  2. If necessary, set the Active if binding is a property (see also the example at the end of this section). This option is enabled when other Data Classes inherit from the Data Class defined in the Data Class Control. If the Data Class Control is folded, you can select the underlying Data Class (default) or any of its children Data Classes in the selector. Your selection determines if and how this Control is rendered by the auto-generated UI: the Control is only considered if the instance found at runtime is of the type selected in the Active if binding is a option or is null.
    Note: When you unfold the Data Class Control, Controls for all properties of the Data Class selected in Active if binding is a are created. After unfolding, Active if binding is a cannot be modified.

    The Active if binding is a property is automatically updated when the binding of the Control is set, updated, or removed. Specifically:
    • When the binding is set: If there is one single compatible Data Class, such Data Class is preselected.
    • When the binding is updated:
      • If the selected Data Class is still compatible, such Data Class is kept;
      • If the selected Data Class is no longer compatible, and there are more compatible Data Classes, the Business Object selector is displayed;
      • If the selected Data Class is no longer compatible, and there is one single compatible Data Classes, such Data Class is selected.
    • When the binding is removed: The 'Active if binding is a' property is unset.
  3. Set the Label and Extended Label properties (see the Labels and Translation) section for details).
  4. Consider the following information on the Unfold option before unfolding the control. When a Data Class Control is folded, the underlying Data Class is responsible for the structure rendered by the auto-generated UI. Any change made to this Data Class (adding properties, removing properties, changing the property type etc.) is immediately reflected when the auto-generated UI renders the output of the Data Class Control.
    Unfolding a Data Class Control means that you become responsible for the structure, through the settings you make in the Data Logic.
  5. After considering the information above, click on the Unfold button to access the properties of a Data Class Control (a nested, separate Control with a fixed binding is created for each property).
  6. Set Sentries for individual properties (see the note on sentry), rearrange the properties nested below the Data Class Control, or remove properties which are not needed. The only changes made to the underlying Data Class that have an immediate effect in the auto-generated UI when rendering the output of an unfolded Data Class Control are: removing a property from the Data Class and changing the type of a property of the Data Class.
    Notes:
    • If you remove the Control for a property after unfolding a Data Class Control, you can add it back by selecting Add Data Property from the right-click menu of an unfolded Data Class Control.
    • You can refold a Data Class Control by selecting Re-fold Control from the right-click menu of an unfolded Data Class Control. Refolding an unfolded Data Class Control means that the responsibility is returned to the Data Class: All settings made in the Data Logic editor for properties of the Data Class Control are discarded, making refolding a disruptive action.

Example - Active if binding is a
To understand the exact implications of setting Active if binding is a, consider the following scenario: A Data Class 'Party', containing the property description has a child Data Class called 'LegalEntity', with the properties name and vatId. Depending on your settings, the behavior is as follows:

Variable Type Runtime Type Active if Setting Rendered Data
Party Party Party Party properties
Party Party LegalEntity Nothing
Party LegalEntity Party Party properties
Party LegalEntity LegalEntity Party and LegalEntity properties

4.2.3 Collection

A Collection Control is created for an indexed or named collection. A Collection Control defines an iteration over the items inside the collection. You can add/remove items contained inside as needed.

  1. To create a Collection Control, drag it from the Controls section in the right-side library. Expand and collapse the elements inside the Collection Data Control using the 'Expand' arrow icon on the left side of the Control. Two sections are available. Collection and Element.
  2. In the Element section, the Index Variable or Name Variable field (for Indexed Collections and Named Collections, respectively) allow specifying the variable that refers to the current element of the iteration. A default is provided, but can be overridden if necessary.
  3. Define sentries (see also the note on sentries section above):
    • In the Collection section, you can configure the Sentries for the collection as a whole.
    • In the Elements section you can configure the Sentries for each element of a collection individually (this setting is available only for Collection of Data Class instances, not for Collections of Primitive types) by providing: an Index Variable for Indexed Collections; a Name Variable for Named Collections. Use this Sentry to define which elements of a Collection can be removed. Consider the following combinations for the Collection Sentry (C) and the Element Sentry (E):
      • C= Enabled & E = Enabled (Elements can be added and removed)
      • C= Enabled & E = Disabled (Elements can be added but not removed)
      • C= Disabled & E = Enabled (Elements can be removed but not added)
      • C= Disabled & E = Disabled (Elements cannot be added nor removed)
  4. You can set the Label, Extended Label and Add Button Label properties (see the Labels and Translation) section for details).
    Note: The Label and Extended Label properties shown for the previous Iterator Control (no longer available starting from Appway 11.1) are now located in the Elements section of the Collection Control. These are only shown if a value was previously set for them, otherwise they are not displayed.
  5. In the Update Function field, you can specify a logic to be executed when changes are made on the Control in the Workspace. Select a Script Function Business Object: this is executed when elements are added or removed from the Collection in the Workspace. Consider the following information:
    • When an Update Function script changes a value on another field, the Update Function script is not executed on that field, meaning that each Update Function needs to be self-sufficient and execute all the necessary changes by itself.
    • The Update Function is executed even if there are validation messages on the field.
    • The Update Function must be simple and lightweight: heavy functions would have a highly negative impact on performance. Moreover, Integration Calls (Database queries, Web Services call and so on) should be avoided. In general, we recommend using this setting only when strictly necessary, so as not to affect Solution maintainability.
      The System Health Sensor Data Logic Update Function Execution Time checks the average execution time of Update Functions defined in Data Logic Business Objects to ensure optimal UX. See full information.

4.3 General Controls

Create these Controls by dragging the according object from the Controls panel on the right.
The following General Controls are available:

  1. End Task Action (deprecated)
  2. Start Subprocess Action (deprecated)
  3. Section Group
  4. Field Set Group
  5. Text
  6. Data Logic Include

4.3.1 End Task Action (Deprecated)

The End task Action is deprecated in Appway 11 and will be removed in two years or later. Check deprecation information. Moreover, consider that App Tasks (currently, the Data Gathering App Task) ignore all Action Controls added to Data Logic Business Objects in Appway 11 and higher.

The End Task Action Control allows the end user to end the Data Task or App Task.

  1. To create an End Task Action Control, drag it from the Controls section in the right-side library, and set its properties:
  2. Set the Action Value property, which determines where in the Process flow the end user continues after ending the Data Task or App Task. The End Task action is enabled in the auto-generated UI only if all the following conditions apply:
    • The sentry expression of the End Task Action Control returns DataLogicControl.SentryState.ENABLED().
    • There are no active Tokens for Subprocesses of the current Data Task or App Task (see the Start Subprocess Action Control section just below).
    • There are no violations to Rules whose Blocking setting returns true (see the Data Rules Tab section).
  3. Optionally, set the Has Icon / Icon Type property. It is possible to specify an icon for this Control by selecting the Has Icon checkbox. An icon can be chosen from the set of default icons provided by the Platform or by selecting a Resource Business Object. The custom icon is displayed next to the Control in the editing area for easier visual identification. If no custom icon is selected, the default icon for that Control is displayed.

4.3.2 Start Subprocess Action (Deprecated)

The Start Subprocess Action is deprecated in Appway 11 and will be removed in two years or later. Check deprecation information. Moreover, consider that App Tasks (currently, the Data Gathering App Task) ignore all Action Controls added to Data Logic Business Objects in Appway 11 and higher.

This Control allows the end user to start a Subprocess.

  1. To create a Start Subprocess Action Control, drag it from the Controls section in the right-side library, and set its properties:
  2. Select the Hidden checkbox if the activity should not be visible as a Workitem in the Worklist.
  3. Select the Follow Started Process checkbox if the end user should be redirected to follow the newly started Subprocess.
  4. From the Process selector, choose the Process to use.
    You can open the selected Process by double-clicking on the Control, or by right-clicking on it and then selecting the Open Process button.
  5. Optionally, set the Has Icon / Icon Type property. It is possible to specify an icon for this Control by selecting the Has Icon checkbox. An icon can be chosen from the set of default icons provided by the Platform or by selecting a Resource Business Object. The custom icon is displayed next to the Control in the editing area for easier visual identification. If no custom icon is selected, the default icon for that Control is displayed.

4.3.3 Section Group / Field Set Group

These Controls have been designed to be used specifically with the Data Gathering App Task. See usage details in the Page Navigation section.

The Section Group and Field Set Group Controls allow the end user to group other Data Logic Controls:

  • The Section option is used when defining an element of the navigation structure in the Workspace.
  • The Field Set option is used when indicating that some fields are closely related and should, therefore, be shown close to each other, for example the street name and street number fields of an address.

The context menu includes the Remove, Keep Children option, which allows removing the main Group control while keeping its children (if any).
  1. Drag a Section Group or Field Set Group Control into the main editing area. A Group Control is created with the Type property set to Section or Field Set, respectively. Set its properties:
  2. Optionally, set the Has Icon / Icon Type property. It is possible to specify an icon for this Control by selecting the Has Icon checkbox. An icon can be chosen from the set of default icons provided by the Platform or by selecting a Resource Business Object. The custom icon is displayed next to the Control in the editing area for easier visual identification. If no custom icon is selected, the default icon for that Control is displayed.

4.3.4 Text

The Text Control has been designed to be used specifically with the Data Gathering App Task. See usage details in the Data Logic Configuration section.

The Text Control allows showing read-only text in the Workspace. The text can be dynamic, that is, it can be the result of a calculation.

  1. Drag a Text Control into the main editing area.
  2. In the Text field, select the Label Business Object corresponding to the text to be displayed (see more information in the Label section).
  3. In the Type field, select the type of text to be displayed (Information or Alert). These result in different styling of the text in the Workspace.
  4. Optionally, fill the Read More URL (you can enter any valid URL) and Read More Label (you need to select a Label Business Object) fields to provide the end user with a link to get further information (e.g. a link to some knowledge base, tax authority page or government website).
    This feature will be available in Data Gathering v2.4 and higher.

4.3.5 Data Logic Include

Data Logic Include Controls allow including Controls defined in another Data Logic Business Object. Such Controls are included in the location of the Data Logic Include Control at runtime (when the Data Logic is evaluated by the Data Engine).

To create a Data Logic Include Control:

  1. Drag your desired Data Logic Business Object from the right-side library (Data Rules section) into the Controls tab, and fill the Variable Assignments fields that are displayed.
  2. Alternatively, drag a Data Logic Include Control from the Controls section in the right-side library, then select the Data Logic, and fill the Variable Assignments fields that are displayed.

    You can open the selected Data Logic by double-clicking on the Control, or by right-clicking on it and then selecting the Open Data Logic button.

    Note that, unlike other Controls, the Data Logic Include Control does not have Name, Label and Extended Label settings, since it is replaced by its content at runtime.
  3. Click on the 'Expand' arrow icon on the left of the Control header, to display a preview of the Control being included.
    You can include the current Data Logic using a Data Logic Include Control to represent cyclic data models.

For more information, see also the Data Logic Include Rules section.

5 Data Rules Tab

The Data Rules tab defines the Rules that data must fulfill to be business-compliant. In other words, if all the Rules in the Data Rules tab are fulfilled (that is, return true), a Data Context can be considered valid according to the business logic.
There are different types of Rules with different purposes, e.g. checking if a person has a required minimum age, or if the provided ZIP code is valid with respect to the standard of the selected country of residence.
To create a Data Logic Rule, drag it into the Data Rules area from the panel on the right.

Starting from version 2022.2, copy-paste options are available from the context menu for Data Rules (Copy Rule, Paste Rule). These are also supported by shortcut keys. Note that both paste options alway paste Data Rules at the bottom.

DataLogicRules.png

Consider the following information on the Data Rules editor:

  • Order — Rules are shown in the editor in the order in which they were added, and such order has no influence on the evaluation of the Rules themselves.
  • Asterisk — Mandatory properties for Data Rules are marked with an asterisk (as wel las reported in the Validation panel on the left). If such properties are not filled, the rule being set is not executed. See also specific information on String rules.
  • Icon color — Each Rule is represented by an icon, and the icon color indicates whether all the mandatory values for that Rule are set. Specifically, the icon is:
    • Gray when one or more mandatory values are not set yet, and the Rule cannot be executed by the Data Engine.
    • Colored when all the mandatory values are set and the Rule can be executed by the Data Engine.
      This is especially useful when you have a series of folded Rules in the editing area.

These are the types of Data Rules that you can define (see details in the sections below):

  • Property Rules
    • Mandatory Fields
    • Catalog Values
    • Single Property Expression
    • String
    • Email
    • Phone Number
  • Data Class Rules
    • Eligible Types
    • Multiple Properties Expression
  • Data Context Rules
    • Cross-Data Class Expression
  • Other
    • Data Logic Include

Note on Data Classes used as bindings in Data Rules — Consider that only Data Classes with static functions used in scripts are replaceable. See the Replacing Business Objects section.

5.1 Mandatory Fields

The Mandatory Fields Data Rule allows defining the list of properties in a Data Class that must be filled in by the Workspace user.

The Mandatory Fields Data Rule has been designed to be used specifically with the Data Gathering App Task. See usage details in the Violation Prevention section.

To create a Mandatory Fields Data Rule:

  1. Drag the Mandatory Fields Rule from the Data Rules panel on the right side.
    Select the Data Class for which mandatory fields are being defined from the Data Class selector.
    Tip: You can open the selected Data Class by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Class button.
  2. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  3. In the Message field, select a Label Business Object. Its text is displayed in the Workspace to mark the mandatory fields. Optionally, to provide more contextual information in the message, use the implicitly defined and automatically set the $instance variable to access the instance of the Data Class to which the Rule is being applied. A default message (“This field is required”) is provided in the Label aw.DataLogic.defaultMandatoryMessage located in the Base Package.
  4. Define the set of mandatory properties of the selected Data Class. Add them in the Mandatory Fields section by clicking on the Add Field button and selecting them one by one from the dropdown list. Only properties of type Primitive Type, Single Element can be selected.
  5. Optionally, in the Enabled field, specify under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  6. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.

5.2 Catalog Values

A Catalog Values Rule defines the set of valid values that a field can contain. The values are taken from a Catalog Business Object. The Workspace may use this Rule to change how it renders controls, for example to render a dropdown list instead of a plain text field, forcing the user to select a valid value.

To create a Catalog Values rule:

  1. Drag the Catalog Values Rule from the Data Rules panel on the right side.
  2. Select the desired values from the Data Class and Property selectors. They represent the Data Class and the properties whose valid values are being defined. In case of collections, the Rule is applied to each element. Note also that only properties of supported Primitive Types (String, Long, Integer, Boolean, Date, Money) can be selected. See the complete list of supported values for the id column and its compatibility matrix with the property type in the attached document (PDF).
    You can open the selected Data Class by right-clicking on the Rule, and then selecting the Open Data Class button.
  3. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  4. In the Catalog selector, select the Catalog Business Object to be used as a source for the valid values. The id column of the Catalog is used as a source of the values, therefore its content must be compatible with the type of the selected property. Then, from the Column dropdown list, select the column of the Catalog from which to take the display values. The content of this column must be a String.
    Note that, if the Data Class Property is set to Boolean, the selected Catalog must contain exactly two records and their id columns must be set to true and false, respectively.
  5. The Catalog Size dropdown allows specifying whether the Catalog returns a small or a large number of results. This setting is used by the Workspace to provide a user-friendly, fast experience. For example, the Data Gathering App Task can determine to show controls connected to large Catalogs as a searchable dropdown list, and use a static checkbox list, instead, for small Catalogs.
    This property has been designed to be used specifically with the Data Gathering App Task. See usage details in the Violation Prevention section.
  6. In the Message field, select a Label Business Object. Its text is displayed if the property value is not among the valid ones defined by the Catalog. Optionally, to provide more contextual information in the message, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule. A default message is provided in the Label aw.DataLogic.defaultCatalogRuleMessage located in the Base Package.
  7. If applicable, you can define Variable Assignments and use the implicitly defined and automatically set $instance variable, which provides access to the instance of the Data Class where the Rule is applied.
    Variable Assignment Example: When a user selects the country of their address, the cities dropdown list for selecting a city should only contain the cities of the selected country. This can be achieved by assigning the selected value of the country ($instance.country) to the Catalog that contains all cities. The Catalog can then be filtered by the country selected by the user to restrict the set of cities.
  8. Optionally, in the Enabled field, define an expression that specifies under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  9. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule.

Note that the situation in which multiple Catalog Values Rules are enabled at the same time for a given field is treated as an error.

5.2.1 Catalog Lazy Loading

Large Catalogs that satisfy the requirements listed below can be configured for lazy loading. Lazy loading allows sending only a subset of Catalog records to the UI, based on a search string entered by the user. This is useful for performance reasons when the Catalog is very large or when its content comes from an external system.

This feature may be used in all App Tasks through the Typehead component and is subject to separate surcharge. See the Data Gathering Licensing article for detailed information.

This option is only available when a Catalog satisfies the following requirements:

If these conditions are satisfied, the Catalog Values Data Rule displays the additional Lazy Loading option. If this checkbox is selected, lazy loading is enabled and must be further configured.
The developer, in fact, needs to select the inputs provided to the selected Catalog so that its results are filtered according to the search performed by the user in the Workspace (see example below). This filtering relies on a set of inputs that are provided to the Catalog through automatically populated Assigned Variables.

The Catalog Values Data Rules provides selectors for four Assigned Variables:

  1. Filter Variable — The Assigned Variable defined in the selected Catalog is automatically populated with the search string entered by the user in the Workspace. This value must be used in the Catalog to return only the records that match the search string based on the desired filtering logic. The variable must be of type String. For example, if the Catalog Values Data Rule is used to let the user choose among a list of Countries and the Lazy Loading option is enabled, when the user enters the letters "uni", the variable selected in the Filter Variable option contains the String "uni" and the Catalog must use it to return only countries whose name or code (depending on the desired logic) contains or starts with (depending on the desired logic) "uni" (e.g., "United States", "United Kingdom", and so on). If the Catalog source is a database, this logic can be implemented in the Catalog using a query with a LIKE clause, for example (See also Data Logic: Lazy Loading of a Database-Sourced Catalog).
  2. ID Match Variable — The Assigned Variable defined in the selected Catalog is automatically populated with the collection of Catalog record IDs to be checked for validity. This collection can contain one or more values and must be used in the Catalog to return only the records whose Id matches exactly one of the IDs provided in the collection. The variable must be an Indexed Collection of type String, Long, Integer, Boolean, Date or Money, depending on the type of the property selected for this Data Rule. Continuing with the example of the Countries Catalog above, this Variable is populated when rendering existing options in the Workspace, such as "UK" or "US" country codes, to check whether they are valid or not. In this situation, the variable selected in the ID Match Variable option of the Data Rule contains Strings "UK" and "US", and the Catalog must use it to return only the records corresponding to those IDs, if found. If the Catalog source is a database, this logic can be implemented in the Catalog using a query with an exact match "=" check, for example (See also Data Logic: Lazy Loading of a Database-Sourced Catalog).
  3. Start Variable — The Assigned Variable defined in the selected Catalog is automatically populated with the index of the next unloaded record of the Catalog that the user has scrolled to, or 0 if the user has not scrolled through results yet. This value must be used in the Catalog to return only the records starting from the position specified in the variable. The variable must be of type Integer.
  4. Limit Variable — The Assigned Variable defined in the selected Catalog is automatically populated with the number of results that should be returned by the Catalog. This value must be used in the Catalog to define the number of records to be returned. The variable must be of type Integer.

Moreover, consider the following configuration information:

  • All four Assigned Variables must be selected in order to properly configure Catalog lazy loading.
  • The four Assigned Variables can be created either manually or automatically in the Catalog Business Object editor by right-clicking anywhere in the Variables tab and selecting the option Create Lazy Loading Variables, which creates the four variables $filter, $idMatch (Indexed String by default), $start and $limit. If these variables exist in the Catalog selected in the Catalog Values Data Rule (Catalog dropdown), they are automatically populated when the Lazy Loading option is enabled.
    Consider that these variables cannot be assigned manually using the Variable Assignments option displayed next to the Catalog dropdown.

Catalog Lazy Loading: Runtime Cases

Since the user interacts with selectors in the Workspace, two cases are possible:

  1. Case: The user enters a search text and scrolls through matching results
  2. Case: One or more values have been previously set in the selector and must be validated by the Data Rule

See details for the two cases below:

  1. Case: The user enters a search text and scrolls through results
    In this case, the four Assigned Variables selected in the Catalog Values Data Rule have the following values:
    • Filter Variable: the search text entered by the user
    • ID Match Variable: null (not relevant)
    • Start Variable: 0 for the first load of the result or the offset based on the scrolling position if the user is scrolling through the results (positive number)
    • Limit Variable: the number of records to be returned by the Catalog, defined by the UI.
      The Catalog must return only the records that match the search text provided in the Filter Variable (according to the desired logic), and must also limit the results based on the provided start and limit numbers. Make sure that the sorting of the returned records is stable and consistent across invocations of the Catalog, so that scrolling behaves correctly (for example in case of a Database-backed Catalog use an ORDER BY clause in the SQL Query to sort the rows). The results are used in the Workspace to render the list of matching options.
  2. Case: Values have been set in the selector and must be validated by the Data Rule
    In this case, the four Assigned Variables selected in the Catalog Values Data Rule have the following values:
    • Filter Variable: null (not relevant)
    • ID Match Variable: list of current property values to be checked for validity (can be empty)
    • Start Variable: not relevant
    • Limit Variable: not relevant
      The Catalog must return only the records whose ID matches one of the values provided for the ID Match Variable. Results are used in the Workspace to render the existing values and validate them. If the Catalog does not return a result for one of the values provided for the ID Match Variable, that value is considered invalid and reported as such in the Workspace. If the property selected for the Data Rule is a Single Element, Id Match Variable contains a single value; if it is a collection, it can contain multiple values. If no value is currently set in the property, it contains an empty collection and the Catalog must not return any result.

Note: When using App Tasks, only these two runtime cases must be supported in the Catalog. For example, Filter Variable and ID Match Variable are never populated at the same time.

An example of how to configure lazy loading for a database-sourced Catalog is available in the Data Logic: Lazy Loading of a Database-Sourced Catalog article.

5.3 Named Collection

A Named Collection Data Rule allows defining constraints on Named Collection Data Class properties, such as the set of valid values for the keys of the collection, taken from a Catalog Business Object.

  1. Drag the Named Collection Rule from the Data Rules panel on the right side.
  2. Select the desired values from the Data Class and Property selectors. They represent the Data Class and the properties whose valid values are being defined.
  3. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  4. In the Collection Keys Catalog selector, select the Catalog Business Object to be used as a source for the valid values of keys in the Collection. The id column of the Catalog is used as a source of the values, therefore its content must be of type String. Then, from the Catalog Label Column dropdown list, select the column of the Catalog from which to take the display values. The content of this column must be a String.
    You can open the selected Catalog by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Catalog button.
  5. The Catalog Size dropdown allows specifying whether the Catalog returns a small or a large number of results. This setting is used by the Workspace to provide a user-friendly, fast experience. For example, an App Task can determine to show controls connected to large Catalogs as a searchable dropdown list, and use a static checkbox list, instead, for small Catalogs.
    This property has been designed to be used specifically with App Tasks. See usage details in the Violation Prevention section.
  6. In the Message field, select a Label Business Object. Its text is displayed if the property value is not among the valid ones defined by the Catalog. Optionally, to provide more contextual information in the message, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule. A default message is provided in the Label aw.DataLogic.defaultCatalogRuleMessage located in the Base Package.
  7. Optionally, in the Enabled field, define an expression that specifies under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  8. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule.

5.4 String

A String Rule allows defining constraints on a Data Class property of type String, such as the maximum and minimum size of the String. String Data Rules are not evaluated on empty fields.
Moreover, consider that you can apply multiple String Rules on a property (see section below).

The String Data Rule has been designed to be used specifically with the Data Gathering App Task.

To create a String Data Rule:

  1. Drag the String Rule from the Data Rules panel on the right side.
    • From the Data Class selector, select the Data Class whose String property constraints are being defined.
      Tip: You can open the selected Data Class by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Class button.
    • From the Property selector, select the property of the Data Class whose constraints are being defined. Note that only String properties can be selected. In case of collections, the Rule is applied to each element.
  2. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  3. Define the constraint(s) to be applied to the selected String property using the settings:
    You need to set at least one of these constraints for the rule to have effect.
    • Minimum Length: the minimum allowed length for the String contained in the Data Class property (default value is 0).
    • Maximum Length: the maximum allowed length for the String contained in the Data Class property (default value is unlimited).
    • Accepted Characters: the characters that are accepted inside the String contained in the Data Class property.
    • Accepted Case: the case types (lower case, UPPER CASE) that are accepted inside the String contained in the Data Class property.
  4. In the Message field, select a Label Business Object. The text of the Label (e.g. "This text must be longer than 10 characters") is displayed in the Workspace to guide the user in entering a correct value for the field. Optionally, in order to provide more contextual information in the message, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  5. Optionally, in the Enabled field, specify under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  6. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule.

5.4.1 Email

The Email Rule is a special type of String Data Rule that allows defining additional constraints on a String Data Class property which contains an email address. The Workspace may use this Rule to change how it renders the corresponding input control, for example to provide the email keyboard for input on mobile devices.

The Email String Data Rule has been designed to be used specifically with the Data Gathering App Task.

The steps required to add and configure an Email Rule are the same as for the String Data Rule (see previous section), with the following specific features:

  • Email Rules automatically validate that the property value is in the format a@b.c where a and b are any sequences of characters without white spaces and c is any sequence of at least 2 characters without white spaces.
  • The Minimum Length constraint is set to 6 and cannot be modified.
  • The Accepted Characters constraint is set to Any and cannot be modified.
  • The Message field contains the default Label  aw.DataLogic.defaultEmailRuleMessage located in the Base Package.

5.4.2 Phone Number

The Phone Number Rule is a special type of String Data Rule that allows defining additional constraints on a String Data Class property which contains a phone number. The Workspace may use this Rule to change how it renders the corresponding input control, for example to provide a dropdown selector for the prefix.

The Phone Number String Data Rule has been designed to be used specifically with the Data Gathering App Task.

The steps required to add and configure an Phone Number are the same as for the String Data Rule (see previous section), with the following specific features:

  • The Prefix Catalog selector (optional) allows selecting a Catalog Business Object as a source for the valid phone number prefixes. The Catalog must contain these columns: Prefix (must start with +, e.g., +39), CountryCode (e.g., IT), CountryName (e.g., Italy).
    • Phone Numbers stored in the property are validated against the selected Catalog, making sure that they start with one of the valid prefixes. Note that Phone Numbers starting with 00 instead of + are also accepted.
    • If applicable, you can define Variable Assignments for the Catalog Business Object and use the implicitly defined and automatically set $instance variable, which provides access to the instance of the Data Class where the Rule is applied.
    • By default, the Catalog DataGathering:Countries is used.
      Note on the DataGathering:Countries Catalog: This Catalog is automatically deployed on the DataGathering extension startup. Consider that this Catalog is just an example, and that the actual Catalog should be created based on your Solution. We recommend that you wrap the Country Description in a Label Business Object. The flag associated to the country is retrieved using the country code.
  • The Minimum Length constraint is set to 7 and cannot be modified.
  • The Maximum Length constraint is set to 15 and cannot be modified.
  • The Accepted Characters constraint is set to Numbers Only and cannot be modified (note that + is accepted for prefixes).
  • The Message field contains the default Label aw.DataLogic.defaultPhoneNumberRuleMessage located in the Base Package.

5.4.3 Multiple String Data Rules

As mentioned above, it is possible to define multiple String Data Rules on the same property. In this case, the following principles apply:

  • Minimum Length: the highest value defined in the various Rules for the property is used to check the validity of the String.
  • Maximum Length: the lowest value defined in the various Rules for the property is used to check the validity of the String.
  • Accepted Characters: the most restrictive option defined in the various Rules for the property is used to check the validity of the String (e.g. if at least one Rule is set to Numbers Only, that constraint applies).
  • Accepted Case: the most restrictive option defined in the various Rules for the property is used to check the validity of the String (e.g. if all Rules are set to Any and one is set to lower case, the lower case constraint applies).

Tip: If you have at least two String Data Rules on the same property, we recommend that each Data Rule defines only one constraint. This ensures that a violation always results in a precise Message.

5.5 Single Property Expression

A Single Property Expression Rule validates one Data Class property of Primitive Type. In case the Rule is violated, the property is highlighted in the Workspace. These Data Rules are not evaluated on empty fields.

To create a Single Property Expression:

  1. Drag the Single Property Expression Rule from the Data Rules panel on the right side.
  2. Select the desired values from the Data Class and Property selectors. These represent the Data Class and property to which the Rule applies. Note that only primitive type properties of a Data Class can be selected. In case of collections, the rule is applied to each element.
    Tip: You can open the selected Data Class by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Class button.
  3. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  4. In the Valid field, enter the expression that specifies the conditions under which the property value is accepted by the Rule. The expression should return true when the value is accepted and false when it is not. Note that this type of Rule is not applied to empty values. Use the implicitly defined and automatically set $valuevariable to access the current value being evaluated by the Rule. Optionally, use the $instance variable to access the instance of the Data Class to which the Rule is being applied.
    Example: To check if the format of an email address corresponds to RFC 5322, use: MATCH($value, '^[a-zA-Z0-9\\.\\-\\_]+@[a-zA-Z0-9\\.\\-]+$'). When checking the validity of the phone number of a client, verify that the number starts with +41 if the client is from Switzerland by using:
    If EQUAL($instance.country, 'CH') Then 
       Return STARTSWITH($value, '+41');
    End
    Return true;
  5. In the Message field, select the Label Business Object whose text should be displayed if the property value is not accepted according to the Valid expression. Optionally, in order to provide more contextual information in the message, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied and the $value variable to access the current value being evaluated by the Rule.
  6. Optionally, select the Allow multiline checkbox this field can contain text with multiple lines or paragraphs. This allows the Workspace to show an appropriate control, e.g. by displaying a text area instead of a text field. This option is only available for String properties.
    If the Data Rule is used only to specify the Allow multiline setting, leave the Valid, Message and Blocking properties empty.
  7. Optionally, in the Enabled field, specify under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  8. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied, and the $value variable to access the current value being evaluated by the Rule.
    Note that it is possible to define multiple Single Property Expression Rules on the same field.

5.6 Eligible Types

The Eligible Types Rule has been designed to be used specifically with the Data Gathering App Task. See usage details in the Violation Prevention section.

Given a Data Class hierarchy where one or more child Data Classes inherit from a parent Data Class, an Eligible Types Rule defines the subset of Data Class types that can be instantiated and stored in a variable, property or collection element of the parent Data Class type. For example, given Data Classes NaturalPerson and LegalEntity inheriting from Person, this rule allows defining that a collection of type Person can contain only instances of NaturalPerson and LegalEntity, but not Person itself.

To create an Eligible Types Data Rule:

  1. Drag the Eligible Types Rule from the Data Rules panel on the right side.
  2. Select the target Data Class for the Rule. The Rule is applied to all variables, properties and collection elements whose type is the selected Data Class, and restricts which Data Classes can be instantiated and stored in the variable, property and collection element.
    Tip: You can open the selected Data Class by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Class button.
  3. Define one or more children Data Classes as eligible in the Eligible Types section. Select a Data Class from the dropdown list and click on Add to define it. For each Data Class, specify the Label that should be used in the Workspace when selecting which Data Class type to instantiate.
  4. The Type Selection Label field determines the label of the selector displayed in the Workspace when selecting which Data Class type to instantiate. A default text is provided in the Label aw.DataLogic.defaultEligibleTypesRuleTypeSelection located in the Base Package.
  5. In the Message field, select a Label Business Object. Its text is displayed if an instance whose Data Class type is not among the eligible ones is found in the Data Context. Optionally, to provide more contextual information in the message, use the implicitly defined and automatically set $instanceTypeLabel variable to access the default Label Id corresponding to the Data Class Instance to which the Rule is being applied (default Labels are in the format [LABEL:{PackageId}:aw.DataClass.{DataClassId}]). A default message is provided in the Label aw.DataLogic.defaultEligibleTypesRuleMessage located in the Base Package.
  6. Optionally, in the Enabled field, specify under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled).
  7. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking).

5.7 Multiple Properties Expression

A Multiple Properties Expression Rule validates multiple properties of the same Data Class. In case the Rule is violated, all such properties are highlighted in the Workspace. The rule is evaluated for every instance of that Data Class, including the instances inside collections.

To create a Multiple Properties Expression Rule:

  1. Drag a variable (Data Class) from the left side Variables panel into the Data Rules tab. The Data Class is selected automatically. Alternatively, create a new Multiple Properties Expression Rule manually by dragging it from the Data Rules panel on the right side and select the Data Class the rule applies to.
    You can open the selected Data Class by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Class button.
  2. The Rule Target dropdown allows selecting the set of Data Class instances the Data Rule should be applied to:
    • All instances of the Data Class in the current scope — The Data Rule is applied to all Data Class Instances of the selected Data Class type available in the current scope.
    • Specific instance of the Data Class — The Data Rule is applied only to the Data Class Instance that you specify in the Binding field. The binding should then return a Data Class Instance of the selected Data Class type (or one of its sub-types) which is part of the current scope.
  3. In the Valid field, enter the expression that evaluates whether the properties selected as Affected Fields are accepted by the Rule. The expression should return true when the values are accepted and false when they are not. Use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
    Example:
    Rule: A credit card owner must be 18 or older. Written as a validity expression for a Multiple Properties Expression Rule:
    Return TIMEDIFF($instance.dateOfBirth, TODAY(), 'y') >= 18
  4. In the Message field, select the Label Business Object whose text should be displayed in the auto-generated UI if the values of the properties selected as Affected Fields are not accepted according to the Valid expression. Optionally, to provide more contextual information in the message, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  5. Define one or more Affected Fields by clicking on the Add Field button and selecting them one by one from the dropdown list. Affected Fields determine the properties that are highlighted in the Workspace when the Rule is violated.
  6. Optionally, in the Enabled field, enter an expression that specifies the circumstances under which the Rule must be evaluated (e.g. only for foreign clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.
  7. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking). Optionally, use the implicitly defined and automatically set $instance variable to access the instance of the Data Class to which the Rule is being applied.

Note: If you created the Multiple Properties Expression Rule by dragging in a property of a Data Class, that property is already defined as an Affected Field.

5.8 Cross-Data Class Expression

A Cross-Data Class Expression Rule validates multiple properties of different Data Classes. In case the Rule is violated, all such properties are highlighted in the Workspace. Properties inside collections are not supported, you can only set a Rule for the collection as a whole. Use this type of Rule when it is not possible to use a Multiple Properties Expression Rule, for example when a rule affects fields of multiple, separate Data Classes.

To create a Cross-Data Class Expression Rule:

  1. Drag the Cross-Data Class Expression Rule from the Data Rules panel on the right side.
  2. The Valid field, enter the expression that evaluates whether the values of the bindings selected as Affected Fields (see below) are accepted by the Rule. The expression should return true when the values are accepted and false when they are not.
  3. In the Message field, select the Label Business Object whose text should be displayed in the auto-generated UI if the values of the bindings selected as Affected Fields are not accepted according to the Valid expression.
  4. To define one or more Affected Fields, click on Add Binding and enter the bindings to be validated (e.g. $client.name) one by one. Affected Fields define the fields that are highlighted in the Workspace when the Rule is violated.
  5. Optionally, enter an expression in the Enabled field. This specifies under which circumstances the Rule must be evaluated (e.g. only for foreign Clients). The expression should return false when the Rule must not be evaluated (default is true, meaning it is always enabled).
  6. Optionally, in the Blocking field, specify under which circumstances a violation of this Rule should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the Rule should prevent the execution of selected Process Actions (default is false, meaning it is never blocking).

5.9 Data Logic Include

Data Logic Include Rules allow including Data Rules defined in another Data Logic Business Object. The included Rules are evaluated in addition to the Rules defined in the current Data Logic.

To create a Data Logic Include Rule:

  1. Drag an existing Data Logic Business Object from the right-side library (Data Logic section) into the Data Rules tab and fill the Variable Assignments fields that are displayed.
  2. Alternatively, drag in a Data Logic Include Rule from the Data Rules section in the right-side library, then select the Data Logic, and fill the Variable Assignments fields that are displayed.

    You can open the selected Data Logic by double-clicking on the Rule, or by right-clicking on it and then selecting the Open Data Logic button.
  3. The Target Scope dropdown allows defining the set of Data Class instances that the included Data Rules should be applied to:
    • Assigned — (default value) the Data Rules are applied only to the Data Class Instances contained in the Variables that are assigned to the included Data Logic (together with the Data Class Instances contained in their properties, at any level).
    • Global — Data Rules are applied to all the Data Class Instances contained in the Data Context, even if they are not explicitly assigned to the included Data Logic.
      Note that Rules created in Appway 10 and lower are set to Global by default, as this was the standard behavior in previous versions.
  4. Select the Iterative Rule Execution checkbox if you want to execute the included Data Rules for each element of a Collection. For example, given an Account Data Model which contains a list of Parties, and each Party has a dateOfBirth and a KYC object, you can use this setting so that the included Data Rules for the KYC object are enabled only if the Party is a not a minor. In this case, enter the following:
    • Collection — The collection for whose elements the Data Rules should be executed.
    • Variable — name of the variable that refers to the current element of the Collection. It can be used in the Variable Assignments of the Data Logic whose Data Rules should be included in the current Data Logic.
  5. Optionally, define an Enabled expression that specifies in which circumstance the included Data Rules must be evaluated (e.g. only for foreign Clients). The expression should return false when the included Data Rules must not be evaluated (default is true, meaning that the Enabled setting of each included Rule is used). The setting is propagated to the included Data Rules as follows:
    • If the Enabled expression of a Data Logic Include Rule returns false, all included Data Rules (recursively) are not evaluated.
    • If the Enabled expression of a Data Logic Include Rule returns true or is not set, the Enabled setting of included Data Rules is used.
  6. Optionally, in the Blocking field, specify under which circumstances a violation of included Data Rules should be considered blocking for the execution of Process Actions. The expression should return true when a violation of the included Data Rules should prevent the execution of selected Process Actions (default is false, meaning that the Blocking setting of each included Rule is used). The setting is propagated to the included Data Rules as follows:
    • If the Blocking expression of a Data Logic Include Rule returns true, all included Data Rules (recursively) are considered blocking.
    • If the Blocking expression of a Data Logic Include Rule returns false or is not set, the Blocking setting of included Data Rules is used.

Technical note: Variable assignments of Data Logic Include Rules cannot use temporary variables defined in the Controls tab, such as Index Variables of Collection Controls.

Technical Notes for the Data Logic Include Control and the Data Logic Include Rule
Included Controls/Rules use the same Data Context as the Data Logic that is including them. However each Data Logic Include Control/Data Logic Include Rule has its own Variable Scope, containing all variables defined in the Included Data Logic. The Variable Scopes corresponding to Data Logic Include Controls/Data Logic Include Rules are re-initialized at each run of the Data Engine.

In general, input data is provided to Data Logic Include Controls/Data Logic Include Rules using Variable Assignments. The content of variables that are assigned from the “root” Data Logic down to Included Data Logic Business Objects is in general part of the Data Context. However, note that the following Data Entities are not part of the Data Context:

  • Data Entities that are only pointed to by Default Expressions of Local Variables defined in included Data Logic Business Objects.
  • Data Entities that are only pointed to by Default Expressions of Assigned Variables defined in included Data Logic Business Objects.
  • Data Entities that are only pointed to by Variable Assignment Expressions of Data Logic Include Controls/Data Logic Include Rules.
  • Assigned variables of Simple Type (Primitive Type, Single Element) defined in included Data Logic Business Objects.

As a result, such entities reside only in the Variable Scope corresponding to the Included Data Logic and they are re-initialized at each run of the Data Engine. Moreover, binding Controls pointing to such Data Entities are not returned in the result of the Data Engine and Rules are not applied to those Data Entities, since they are not part of the Data Context.

Local Variables outside of the Data Context and Assigned Variables of Simple Type in Included Data Logic Business Objects can, therefore, only be used during the run of the Data Engine for temporary calculations and checks.

Example
Given the following Data Logic Business Objects and corresponding Variable definitions:

Data Logic 1
Variables

  • Assigned Person $person

Data Logic 2
Variables

  • Assigned Person $person
  • Assigned Address $address
  • Local Address $secondAddress with default expression $person.address
  • Assigned Address $thirdAddress
  • Local Contract $contract with default expression new Contract;

And given that Data Logic 1 includes Data Logic 2 and assigns

  • the value $person to the $person variable in Data Logic 2
  • the value $person.address to the $address variable in Data Logic 2
  • the value new Address; to the $thirdAddress variable in Data Logic 2

The following behavior applies to the variables defined in Data Logic 2:

  • the content of $person and $address are part of the Data Context since the value is assigned from the “root” Data Logic (Data Logic 1).
  • the content of $secondAddress is also part of the Data Context since, even though the variable is Local, it references something that is already part of the Data Context.
  • the content of $thirdAddress is not part of the Data Context since, even though the variable is Assigned, the Variable Assignment expression does not reference something that is already part of the Data Context.
  • the content of $contract is not part of the Data Context, since the variable is Local and it does not reference something that is already part of the Data Context.

6 Collaboration (Legacy) Tab

The Collaboration (Legacy) tab defines which users are eligible to access a Data Task and the role for which they are eligible.

Collaboration features in the Data Logic are deprecated in Appway 11 and will be removed in two years or later. Collaboration features include: the Collaboration (Legacy) tab in the Data Logic Editor; Collaboration Script Functions; Collaboration Primitive Types. Check deprecation information to evaluate the recommended alternatives.

7 Shortcut Keys in the Data Logic Editor

The following table provides and overview of the shortcut keys (or shortcut key behaviors) specific to the Data Logic Editors.

For information on shortcut keys common to other Business Object Editors, see the Shortcut Keys in Editors document.
Tab Item Shortcut Operation
ControlsAllDDelete
Controls Start Subprocess Action O Open Process
Controls Data Logic Include O Open Data Logic
Controls Data Class O Open Data Class
Controls Data Class A Add Data Property
Controls Data ClassRRe-fold Control
Controls Al CTRL-V Pastes after selected items or at the bottom, if none selected
Data Rules All D Delete
Data Rules Mandatory Fields O Open Data Class
Data Rules Single Property Expression O Open Data Class
Data Rules Eligible Types O Open Data Class
Data Rules Multiple Properties Expression O Open Data Class
Data Rules Data Logic Include O Open Data Logic
Data Rules Al CTRL-V Pastes at the bottom
Correctness Rules (Legacy) All D Delete
Variables Editor (center area) A Copy All Variables Definitions
Variables Declared Variable entry C Copy "{variablename}"
Variables Declared Variable entry A Copy All Variables Definitions

8 Script Function Reference

8.1 Data Rules Script Functions

The following Script Functions are available for retrieving Data Rule information.

  • DataLogic:EvaluateDataRules
    Runs the Data Engine once using the Data Logic with the given ID and the given variable assignments. Returns the result of Data Rules evaluation.

    Parameters
    (String) The ID of the Data Logic to be used
    (Named Any, Optional) The variable assignments for the Data Logic

    Return (DataRules:DataRulesInfo)
    The Rule information resulting from the run of the Data Engine, including Rule violations.

  • EvaluateFilteredDataRules
    Runs the Data Engine once using two provided Data Logic Business Objects containing Data Rules and Controls, respectively. It returns the result of the evaluation of the first Data Logic Business Object (containing Data Rules) considering only those Data Rules that have a corresponding visible Control returned by the second Data Logic Business Object (containing Controls).

    Parameters

    • (String) $dataRulesDataLogicId. The ID of the Data Logic containing the Data Rules to be evaluated. Example: 'AccountOpening:ClientDataRules'
    • (Named Any) $dataRulesVariableAssignments. The variable assignments for the Data Rules Data Logic. Example: {'var' = 'value'}:Any
    • (String) $controlsDataLogicId. The ID of the Data Logic containing the Controls to be used for filtering Data Rules information. Example: 'AccountOpening:ClientControls'
    • (Named Any) $controlsVariableAssignments. The variable assignments for the Controls Data Logic. Example: {'var' = 'value'}:Any

    Return
    Returns DataRules:DataRulesInfo. The DataRulesInfo resulting from the run of the Data Engine.

  • DataLogic:HasDataRuleViolations
    (Available for 2022.2.3 and higher)
    Runs the Data Engine once using the Data Logic with the given ID and the given variable assignments and evaluates the Data Rules specified by the given filter. Returns true if there is at least one violation in the filtered Data Rules.

    Parameters

    • (String) $dataLogicId. The ID of the Data Logic to be used
      Example: AccountOpening:ClientDataRules
    • (Named Any, Optional) $variableAssignments. The variable assignments for the Data Logic
      Example: {'var' = 'value'}:Any
    • (DataRules:Filter, Optional) $dataRulesFilter. The filtering criteria that define the subset of Data Rules to be evaluated
      Example: $dataRulesFilter

    Return (DataRules:DataRulesInfo)
    True if there is at least one violation in the filtered Data Rules, false otherwise

    Example

    DataRules:Filter $filter := new DataRules:Filter;
    $filter.evaluateNonBlocking := true;
    $filter.ruleTypes := [DataRules:Type.mandatoryFields()]:DataRules:Type;
    DataLogic:HasDataRuleViolations('Laura:Client', {'client'=new Laura:Client}:Any, $filter);
    

8.2 Data Logic Context Script Functions

The following Script Function allows checking whether a script is executed in the context of a Data Logic Task or a Data Logic Screen.

  • DataLogic:IsDataLogicContext

    Parameters
    None

    Return (Boolean)
    Returns true if the script is executed in the context of a Data Logic Task or a Data Logic Screen, false otherwise

© 2026 Appway AG. All Rights Reserved