Assignment ruleOfficial Content

Allows you to assign to an attribute or variable, a value that results from evaluating an expression (or a fixed value or a value stored in an attribute or variable).
Attribute assignments imply a data base update.

Syntax

att | &var = expression [ If condition ]   [ on triggering event];

Where:

att | &var
    Is the attribute or variable to be assigned. In case of being an attribute, it cannot be a formula.

expression
    Is any valid expression that can involve constants, functions, variables or other attributes (the result must match the attribute or variable type definition).

condition
    Is any valid logic condition (that can contain the "and", "or", and "not" logical operators).

triggering event
    Is one of the predefined events available in GeneXus for transaction rules, which allows you to define the precise time for executing a rule.

Examples

Customer
{
  CustomerId*      
  CustomerName         
  CustomerAddress      
  CustomerPhone   
  CustomerAddedDate 
  CustomerLastUpdateDate
}  

Customer Rules:

CustomerAddedDate = today() if insert;
CustomerLastUpdateDate = today();
&DiscountPercentage=10 if CustomerAddedDate.year() < 2011;

Scope

Objects Transaction object
Languages .NET, Ruby, Java, RPG, Visual FoxPro, Cobol
   

See also

Assignment command for variables
Assignment command for attributes