Transaction Rules Syntax

Official Content
This documentation is valid for:

Specifies the syntax associated to the Transaction’s rules.

Syntax

<RuleName> [if <condition>] [on <event1>,...,<eventN>] [level <Att1>,...,<AttN>] [dependencies <Att1>;...;<AttN>|<&var1>;...;<&varN>];

View Syntax conventions

Where:

RuleName
      
Specifies a Transaction rule.

condition
       Is the boolean expression that details the conditions that must be fulfilled to trigger the rule. It can be composed of logic operators (and, or, not).

 event1,...,eventN 
        Is the event or list of events separated by “,”. The possible values are AfterInsert, AfterUpdate, AfterDelete, AfterValidate, AfterComplete, AfterLevel, BeforeValidate, BeforeInsert, BeforeUpdate, BeforeDelete and BeforeComplete.

Att1,...,AttN
         Is the attribute or list of attributes separated by “,” determining the level of the transaction where the rule applies; the first level is assumed in case the section level is not specified.

Att1,...,Att&var1,...,&varN
         
Is an attribute (or variable), or a list of them separated by ";". The Dependencies clause determines that the rule will be triggered upon accepting those attributes (variables).

Scope

Objects:  Transaction

Description

The syntax of the transaction rules can be logically divided into two sections: condition and triggering event. The condition section is used to specify an expression that must be evaluated to execute the rule. The triggering event details the events where the rule must be triggered, which are associated with the on and level sections.

Samples

Given the following Transaction object:

Client
{
  ClientId*
  ClientName
  ClientType
  ClientBalance
  Phone
  { 
     ClientPhoneId*
     ClientPhoneNumber
     ClientPhoneDescription
  {
{


The following are some detailed examples using this syntax:

Assigning a value on the AfterValidate (same to BeforeInsert) event:

ClientType = 1 If Insert On AfterValidate;
ClientType = 1 On BeforeInsert;

Calling a Procedure on the AfterInsert or AfterUpdate event:

Proc(ClientId) On AfterInsert, AfterUpdate;

Executing the rule error if a maximum is reached:

Error('Maximum reached') If ClientBalance > &Max On AfterValidate;

Calling a log Procedure on the AfterInsert or AfterDelete event:

Proc1(ClientId, &Mode) On AfterInsert, AfterDelete;

Calling a Procedure after the level associated with the attribute ClientPhoneId:

Proc2(ClientId) On AfterLevel Level ClientPhoneId;

See Also

Transaction rules
Triggering events for rules in Transactions