About Rules

Rules are simple “IF…THEN…ELSE” user-defined statements that are grouped to implement functions. In InterPlay, rules are used to:

  • Change dynamically the forms when the user is entering data.

Rule Sample 1:

Definition

field = getField(“Operation”)

If AccountType1=”Type1” and AccountType2=”Type2”

Then field.visible=true

Else field.visible=false

In this example the “Operation” field becomes visible when AccountType1 equals ”Type1” and AccountType2 equals ”Type2”. This rule can be triggered when the object editor is opened and when AccountType1 or AccountType2 properties are modified.

  • Control and update the data entry.

Rule Sample 2:

If AccountType1=”Type1”

Then AccountType2=”Type2”

Else newError(“Code1”, “Account is invalid”)

In this example when the AccountType1 property is equal to ”Type1” then the AccountType1 property is set to ”Type1” else an error is raised. This rule can be triggered when the AccountType1 property is modified.

  • Control and transform data that are imported by the user.

Rule Sample 3:

Definition

var = customFct(ds.prop4);

If ds.DIRECTION=”C”

Then e = new Object(“”);

e.prop1=ds.prop1;

e.prop2=ds.prop2;

e.prop3=”QTE”;

e.prop4=var;

In this example when the DIRECTION field of the given line on the imported file is equal to ”C” then a new Object is created and initialized with values from the imported line, given statically or computed using a custom function. This rule can be triggered when a given file is imported.

Rule definition

A Rule is defined by a:

  • Name that identifies the rule in the library
  • Description
  • Priority that orders the rules execution
  • Type that defines the actions the rules are authorized to perform: Change Field; Control, Modify, Transform
  • Packet that defines a group for the rules. Functions are linked to packets of rules and thus execute a set of rules.
  • Validity period
  • Path to the target object:
    • Collection type and version if the target is a collection.
    • Object type and version if the target is an object. The Collection type and version can be specified as well if the rule uses Collection properties.
    • Object type, version and Element type name if the target is an element.
  • Scope that determines on what type the rule applies: a certain tag or one or several versions of the given object type.
  • Library list that contains ExecuteFunction functions that are used in the rule.
  • For Transform rules, the datasource information gives to the rule the format of the imported file.
  • Body that defines the rule expression.

Rule execution

InterPlay calls the functions that have been defined in the Designer at extension points. At execution time, the list of rules that are referenced by the Rule-based function is filtered to keep only the valid rules. All valid rules are then executed according to the priority order set on the rules.

A rule is valid if the:

  • Type is compatible with the function type.
  • Current date is part of the rule validity period.
  • Object the rule is applied upon is compatible with the rule definition (tag, object type name and version).
  • Properties used in the rule body are found in the target type.

Related Links