Rule types

About Rule types

A Rule type specifies the class of the rule behavior. In the runtime, the rules that are executed in a rule-based function are filtered according to their type in addition to the business entity type and validity interval.

Control

You use the control rule to check the business data and create business errors. You are not allowed to assign business properties in control rules. The rule editor in the Designer prevents this.

Modify

You use the modify rule to alter business properties and/or create business errors.

Change Field

You use the change field rule to alter the User Interface fields. A User Interface field is represented in the rule by a variable of Field type, whose value can be initialized with the return value of the getField function.

A variable of type Field has the following properties:

  • visible
  • editable
  • foregroundColor
  • editBackgroundColor
  • backgroundColor
  • fontFamily
  • fontSize
  • fontModifier
  • labelFontFamily
  • labelFontSize
  • labelForegroundColor
  • labelBackgroundColor
  • labelFontModifier
  • label
  • require
  • description
  • mask
  • pattern
  • precision

Example

In this example, the change field rule sets PROP2 as visible only if PROP1 value is “A”.

Definition

f1 = getField(“PROP2”)

if obj.PROP1 = “A”

then

f1.visible = true

else

f1.visible = false

Transform

You use the transform rule to transform records into Objects and Elements during CSV import. The “ds” variable represents the current row from the input file.

Predefined Variables in Transform Rules

Name Use
coll Always defined.
obj

Only defined on Element levels.

The Path in the rule definition contains at least one slash and represents the parent (root) business object.

Example: Path = “doc/line” or “doc/line/line2”

elt

Only defined on sub-Element levels.

The Path in the rule definition contains at least two slashes and represents the parent of the current element (the parent being also an element).

Example: “doc/line/line2”, “doc/line/line2/line3”)

ds Always defined

Example 1 - Rules for importing elements

If the column AMOUNT value in the file is:

  • Negative, the transform rule sets the DIRECTION property of the imported object to “D”.
  • Strictly positive, the transform rule sets the DIRECTION property to “C” and the AMOUNT property value to the absolute value of AMOUNT column.
  • Zero, the line is not imported.

// ruleA of type transform priority = 10

if ds.AMOUNT < 0 then

e = newElement(“1”, obj)

e.DIRECTION = “D”

 

// ruleB of type transform priority = 10

if ds.AMOUNT > 0 then

e = newElement(“1”, obj)

e.DIRECTION = “C”

 

// ruleC of type transform priority = 5

Definition

e = getElement(“1”)

If e is not null Then

e.AMOUNT = ds.AMOUNT

e.OTHER_PROP = ds.SOME_PROP

Example 2 - Rules for importing virtual objects

// ruleA - creates the object

// Path = "/doc"

definition

obj = getObject(ds.ACCOUNT)

if obj is null

then

obj = newObject(ds.ACCOUNT)

obj.ACCOUNT = ds.ACCOUNT

 

// ruleB - creates the elements for debit operations

// Path = "/doc/line"

if ds.DEBIT is not null

then

elt = newElement(“D”, obj)

elt.DIRECTION = “D”

elt.AMOUNT = ds.DEBIT

 

// ruleC - creates the elements for credit operations

// Path = "/doc/line"

if ds.CREDIT is not null

then

elt = newElement(“C”, obj)

elt.DIRECTION = “C”

elt.AMOUNT = ds.CREDIT

Related Links