Rule execution

The rules are executed only by the means of the functions. In the Designer, the user defines a rule-based function in the same place where regular functions are defined, by selecting:

  • "Rules" as implementation.
  • The library that contains the rules.
  • A list of packets.

The types of the functions that can be implemented with rules are: Control, Modify, Change Field, Execute Action, Transform Import and Control Import.

An argument of the function is visible in rules by defining in the rule body a variable with the same name as the argument, but without the initialization (only variable name and type).

Execution conditions

The rules that are executed by a function are the ones that meet all the following conditions:

  • The packet is in the packet list of the function.
  • The type is compatible with the function type (see Rule type compatibility).
  • The current time (of execution) belongs to the interval [“Valid From” - “Valid To”] or both “Valid From” and “Valid To” are empty or “Valid From” is empty and the current time is less than or equal to “Valid To” or “Valid To” is empty and the current time is greater than or equal to “Valid From”.
  • The current entity (Tag, Collection, Object or Element) is compatible with the rule. It is considered compatible if all the following conditions are true:
    • The path of the current entity is compatible with the rule element path: the rule element path is empty or the current entity is a business object or element and the path of the entity is the same as the rule element path.
    • The current entity type is compatible with the rule collection type and version and object type and version. This compatibility depends on the Scope property of the rule:
      • Tag - the rule is compatible with every object type with this tag.
      • Versions - the rule is compatible with the specified versions of the specified Collection Type and Object Type.
    • The current entity types (Tag, Collection Type, Object Type and Element Type) contain all the business properties referenced in the rule body.

Rule type compatibility

Rule Types Function Types
Control Modify Change
Field
Execute
Action
Transform
Import
Control
Import
Control Yes Yes   Yes Yes Yes
Modify   Yes     Yes Yes
Change Field     Yes      
Transform         Yes  

Packet list

The packet list in the function definition is an ordered list. The rules are executed in the order of the packet list and the rules of the same packet are executed in the descending order of the priority. If two or more rules of the same packet have the same priority, they are executed in the lexicographical order of their names.

The user can also specify which groups of packets to run by using a wildcard character: %. For instance, if a Control function on an object editor must execute the rules inside Pack1 and another Control rule must execute rules inside Pack2 at import, it might be necessary to execute both packets of rules at save; in this case, the user can enter the Pack% value for the PacketList argument and both Pack1 and Pack2, in this order, will be executed at save.

Executing a rule-based Execute Action function

The Execute Action function is used in custom actions. In the Rule language there is no mechanism to iterate through the selected objects, so the rule execution engine will execute the set of rules for the current object and for each selected or filtered object.

The Execute Action function has some special arguments that control the behavior of the User Interface after the execution.

Argument name Type Description
refreshEditor Boolean If true, the current editor is refreshed.
refreshErrors Boolean If true, the error list is refreshed.
refreshList Boolean If true, the collection, object or element list is refreshed.
successMessage String A message to be displayed to the user if the function call succeeds.
errorMessage String A message to be displayed to the user if the function call returns errors.

Related Links