Official Content

The purpose of this article is to describe the general syntax associated to the Transaction object’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 ";", that determines the rule will be triggered upon accepting those attributes (variables). This is because the Dependencies clause is used to indicate attributes and/or variables that once their values are obtained, the rule will be triggered.

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

Rules in Transactions
Triggering events for rules in Transactions



Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant