Assignment Command for attributes

Official Content
This documentation is valid for:

Attribute assignments imply a database update.

If you need to assign a value to an attribute within the definition of an object, the object section where the assignment can be defined depends on the object (for example it can be done in procedures sources inside a For each command or in transactions rules).

The assigned value type must match the attribute type, otherwise a warning message will be displayed in the navigation report.


att operator expression

Attribute to be assigned.

One of the following assignment operators: = , +=, -=, *=, /=.

Assignable expressions are: Attributes, Variables, Constants, Functions and Arithmetic Expressions, Inline Formulas.

Which attributes can be updated?

  • Attributes that belongs to the Base Table you are navigating (in a For each command or in a transaction you have a base table or several base tables).
  • Attritables that can be infered because they belong to the extended table of the base table you are navigating.

If the update is done inside a For each command, the update is performed when the Endfor command of the associated group is encountered. Despite this, attributes referenced after an assignment and before the associated Endfor, will contain the last assigned value.




A Procedure is needed to update all the flight prices.

For each
    FlightPrice = FlightPrice  * 1.10

In this example, since the only attribute included in the For Each command is FlightPrice, the base table navigated by GeneXus is: FLIGHT.

Since no filters have been defined, all the table records will be navigated. For each flight, we update its price, and in this case we increase it by 10%.

We must bear in mind that in a single For Each command we can update several physical tables. Specifically, a For Each command always has a base table that it navigates and can change but it can also change the entire extended table of said base table. In the following example, the base table of the For Each command is FLIGHT, but as each flight has one airline, we could change the details of the airline associated with each flight:

For each
     FlightPrice = FlightPrice  * 1.10
     AirlineName = ‘Copa Airlines’
     AirlineDiscountPercentage = 20


  • It is not valid to assign a value to an attribute when the attribute is part of the index used to scan over the base table. An error will be shown it in the navigation list.
  • Procedures don’t check the consistency of the data we assign. Since data bases check the consistency of interrelated data, when the user runs the application and tries to assign an inconsistent value, the database will reject the operation and the inconsistent data will not be saved. However, the program will stop working and this isn’t very user friendly. Therefore, if we use procedures to update the database, it will be our responsibility to assign valid and well related data.
  • Redundancy will not be automatically maintained when updating the database in Procedures. This maintenance is the programmer's responsibility. That is, if a Redundancy depends on the attribute being updated, GeneXus will not search or calculate data to store it in the redundant attribute.


Objects Procedure object

See also

Updating the database using Business Components
Assignment Command for variables
Assignment rule