Generators
In any document class you can define one or more 'Auto generated' fields (see Field Kind in Class Designer). Auto generated fields are using generators (sequences) to provide their values.
Each generator is used to generate a unique alpha-unique numeric value in a sequential order. By default, generators return numeric values, but you can format that value as needed. For example, in the picture above, TestSequence
generator will produce a value like "INV_2024_7632"
.
The system will automatically generate a value (trigger assigned generator) for each auto-generated field when you call save()
method on your new document.
Sometimes, you will need to know your auto-generated fields values before calling save()
method (for example, other fields depend on it). In that case you can initialize auto-generated field values in your code manualy using initAutoGeneratedValues()
method.
Hint
Once you call initAutoGeneratedValues
method, the system will give you a uniue value that will never be repeated.
A basic generator only requires a definition and does not need coding. To add complexity, override the nextValue
method and return the sequence in your desired format.