NF13 Custom key of document sequence
System Design: Norbert Bede, Cloudempiere
Developer: Peter Takacs, Cloudempiere
Feature Ticket: IDEMPIERE-6575
Custom Key of Document Sequence
This change allows to define a custom key for a Document Sequence, using values from the context of the document. If properly configured, it results in having multiple Sequence Number series (Sequence No tab) for a single Document Sequence.
Changes
- renamed
AD_Sequence_No.CalendarYearMonth
toSequenceKey
and increased the length of the column to 255 - introduced a new “key“ pattern to Prefix and Suffix fields: with that you can define specific values (context variables) that will be added to the
AD_Sequence_No.SequenceKey
Syntax
Add "/K" after the name of the context variable, before the closing '@', e.g. @ContextVariable/K@
How to Configure
Let's configure a Document Sequence for Sales Orders, with custom key that consists of Date Ordered, C_BPartner_ID, and the year that comes from checking the Restart Sequence Every Year checkbox (legacy functionality).
- Define the Prefix or Suffix of Document Sequence like so: @DateOrdered<yy>/K@/@C_BPartner_ID/K@/
- Check the Restart Sequence Every Year checkbox
The resulting custom Sequence Key will look like this: DateOrdered-C_BPartner_ID-Year, where '-' is the separator.
Motivation, example use case
The motivation of this change was to find a solution for performance issues on concurrent document processing. Before, a shared lock could happen when a document was completed (e.g. when having multiple POS terminals in parallel), they were all accessing the same Sequence No at the same time, causing one document to wait for the other, slowing down the system.
After the change it is allowed to define a custom prefix, that will maintain a separate Sequence No for each POS terminal, without the need to define a separate Document Sequence for each. With defining such Document Sequence, every POS terminal's documents are accessing their own Sequence No, avoiding the share lock.