- Builder
- User interface and Navigation
- Sequences Page
Sequences Page
Sequences are designed to provide automatic generation of serial numbers (See System defined shared fields for more details) for Directories, Documents and Reports.
How to use sequences?
For Directories, Documents and Reports property "Sequence" is available on type's details page. When this field is set, each time user creates an instance with no manually defined serial number, system asks selected sequence to generate a new serial number.
Note: Sequences are only used in application. System instances should be numerated manually.
How does sequence generate serial numbers?
Sequences represent a serial number as a concatenation of some fixed string prefix and a numeric value, which is generated each time the sequence being asked to generate a new serial number (e.g. PREF-0001, VAT1712).
When a data type (T) with selected sequence (S) requests a new serial number for it's instance, system acts like this:
- Find last serial number generated by this sequence for this data type. If this sequence have never been applied for this data type before, the initial value defined for this sequence is used. We will refer to this serial number as "a current state of the sequence S for data type T".
- Split this serial number into string-prefix and numeric value.
- Increment numeric value by 1.
- Update the current state of the sequence S for data type T with a concatenation of old string-prefix and new numeric value.
- Return the current state of the sequence S for data type T.
If user manually set a serial number for an instance of type T which uses a sequence S, manually defined serial number is considered to be a new state of S for type T if and only if its prefix differs from a prefix of current state, or its numeric value is greater then numeric value of current state.
Note: If the current serial number conatins leading zero, the sequence will use the same format as long as possible. (E.g next value for A-007 is A-008, but next value for A-999 is A-1000).
- Find the state of S for data type T.
- Let A be a timestamp of the moment when this state was generated. If A and D are inside different periods (e.g. monthes, years, hours, etc.) the initial state is used as the current state of the sequence S for data type T.
- Perform regular serial number generation, which is described above.
Note: If the periodic sequece is also unique, then uniqueness is checked only inside current period. For example, if the period is YEAR we can have both document #A-47 dated 07.04.2017 and document #A-47 dated 07.04.2018.