Defining Datatypes

Item Definitions

User-defined datatypes, called item definitions, are created from built-in types by adding constraints or components. Each item definition has a unique name in the model namespace.

Adding a Datatype

There are multiple ways to add a New type to your model:

  • From a data object, data input, or data output shape, right-click Attributes/Datatype.

  • From the datatype overlay on a diagram shape, click the type name.

  • From the Data Type dialog on the BPMN ribbon, click the Add button.

Any of these present a dialog where you enter the type name, click the link icon at the right and select New type….

add new type

This assigns the default type Any, which you modify by again clicking the link icon and selecting either a Simple type or a Structure.

modifyTypeAny

To change the data type of a type or one of its attributes, clicking on the icon will offer different sources for the type.

Simple type

Select from one of the simple types.

Existing Type

Display a window with the data types that are already used by this model. This list can be searched.

Structure

Create a new data structure inline.

Reuse from graph

Select a data type already defined in another model from the Digital Enterprise Graph.

Reuse from accelerator

Select a data type already defined in an accelerator.

Adding constraints

A new simple type is typically a FEEL base type with added constraints, i.e. limitations on allowed values. To define a constrained simple type, first select the base type from the Simple dropdown and then click on the base type name, such as Text, Number, Boolean, etc. Then select the Constraint type.

data types constraint

The following type of constraints are available

Range

Number, Durations and Date/Time data types support entering a range of values.

Expression

A FEEL expression that defines the constraint on the type.

Enumeration

Most data type allows to enter an enumeration of allowed values for this data type. For textual enumerations, you can paste multiple lines at once from a text file or even Microsoft Excel.

Not null

The data type can never be set to null. Allowed on most data type.

An "Allow null" checkbox can be checked for each constraint except the "Not Null" one.

Clicking the "Add Expression" button allows to enter an additional expression constraint that must be met along with the main one. To delete it, click on the at the top right. Changing the constraint type to "None" will remove the main constraint. If there are additional expression constraints, the first one will be set as the main one.

To refer to the data type itself in an expression, use the question mark "?".

Expression Constraints

An Expression constraint is a Boolean FEEL generalized unary test expression, meaning any literal expression in which the constrained variable is represented in the expression by the ? character. Only values for which the expression is true are allowed. For example, to define tInteger as an integer, use the base type Number and the Expression constraint

? = floor(?)

Since the FEEL function floor() extracts the integer part of a number, this expression is true only for integers.

data types constraint 2

Siblings (same level) of a data type can be referred in an expression using its name.

data types constraint 3
data types constraint 4

Adding collection constraints

When a type is a collection, collection constraints can be defined by clicking at the icon in the namecell. The constraint will apply on the collection itself.

data types collection constraint

The following type of constraints are available

Size

Number of elements of the collection.

Expression

A FEEL expression that defines the constraint on the collection.

Not null

The collection can never be set to null.

Optionals validation code and validation message can also be entered for each constraint. It allows to show a custom error message when the constraint is not respected.

Clicking the "Add Constraint" button allows to enter an additional constraint that must be met along with the main one. The constraint could be Expression, Size or Not null ( Size and Not null are limited to one of each for a collection constraint). To delete it, click on the at the top right.

To refer to the collection itself in an expression, use the question mark "?".

Type Validation Using Constraints

Since DMN 1.5, it is possible to report validation errors at execution time when a variable value does not conform to its type. This option can be turned on or off in File/Preferences.

In the Constraints dialog, you have the option to enter a Validation code and Validation message for each constraint. Both the code and message are returned in the Test action of the Execution ribbon of Decision Modeler if a variable does not conform to its constraint, and are returned in the error message of a deployed decision service as well.

Structured Types

A FEEL variable may be defined as a data structure containing components. Each component has an assigned type, which could be simple, a collection, or a nested structure.

When adding or editing a structured type, the dialog below defines the structure. Numbered rows define the name and type of each component.

data types define

To add a new component to a structure, press the icon at the end of the last component.

Datatype details can be expanded ( ) or collapsed ( ).

Attributes can be reordered using drag and drop.

Right-clicking on an attribute (or using the icon) brings up a contextual menu with localized actions.

Description

Enter a description for the data type or structure attribute.

Insert Row Above

Insert a new attribute row above the current row in a structure.

Insert Row Below

Insert a new attribute row below the current row in a structure.

Delete Row

Delete the current row in a structure.

Cut

Cut the current data type or structure attribute.

Copy

Copy the current data type or structure attribute.

Paste

Paste a data type.

Collection

Toggle the collection attribute of a data type or structure attribute. This displays the collection marker under the label of the data type or structure attribute ( ).

Refactor as a type

Transform an inline-defined structure to a named type that can be referenced by other types.