FAQs
GeneXus

Autonumbering the second level of a transaction

Since the Autonumber property can only be applied to simple primary keys, the Serial rule must be used to number a second level.
This rule requires you to create an attribute at the first level of the transaction, which will store the last value assigned to the second level lines.

Let's see this with an example.
Suppose we have the following two-level transaction to handle the countries and their cities:


The physical table generated from the second level of that transaction is COUNTRYCITY, which is made up of:


It is important to note that the primary key of the table generated from the second level is a compound key (made up of CountryId and CityId).

If we autonumber CityId, we would only be autonumbering part of the table key, and for this reason GeneXus displays a Warning to inform about this. 



This is why GeneXus offers the option to autonumber a second level with the Serial rule.
To do so, add the following rule to the Country transaction:

Serial(CityId, CountryCitySerial, 1);  

CityId is the attribute to autonumber, CountryCitySerial is a new numeric attribute of the Country transaction first level that saves the last entered city identifier, and 1 is the desired increment between records.

You can access the complete documentation from the following link:
https://wiki.genexus.com/commwiki/servlet/wiki?6866,Serial%20rule
 
© All rights reserved. GeneXus™ is registered to GeneXus S.A.