Auto-Numbering with Variables
Starting with version 3.45, we are introducing a new concept called AUTONUM. This is built to allow you to design a true auto-numbering system for your data sets.
In previous versions of docMgt we relied on the [AUTOID] variable which simply used the Record ID value for the unique number. It works great if all you need is a unique number. However, if you need a controllable, truly sequential auto-number system it did not work out as well. The returned numbers would skip values as other records are added which created gaps in the sequence. This is where AUTONUM comes in.
AUTONUM is the name of the variable you can use to get the next available number for a sequence. The simplest use of the variable is [AUTONUM(name)]. In this case a sequence called “name” would be used and the next “name” value would be returned each time it is called. The first time it is called for a given name, the sequence is created. Thereafter, the calls will increment the value and return the next available. Each number is guaranteed to be unique as long as it is not RESET (see below).
For a practical example, we will explain how to use AUTONUM for generating Purchase Order numbers. For this example we might use an E-form to create the purchase orders. In that E-form we will have a field named “PONumber” and will set its default value to “[AUTONUM(PO)]”. When the E-form is first opened the next available PO number will be in the field. The next time one of these E-forms is loaded the next number will be in the field and so on. If 2 people open a new PO E-form at exactly the same time each will get a unique number in that field so there is no worry about duplicates.
At the same time you might also have another AUTONUM sequence called “Invoice”. Those numbers will have their own AUTONUM sequence and will not be related in any way to the “PO” AUTONUM sequence.
There are actually 4 separate variables that help you with the AUTONUM system. AUTONUM, AUTONUMRESET, AUTONUMDELETE and AUTONUMEXISTS.
[AUTONUM(name|start)] – This will return the next available number based on a named sequence. If the named sequence does not exist it will be created. It has an optional parameter named “start” that allows you to set the starting number of the sequence. If you omit this value then the sequence starts at 1. The “start” parameter will be ignored if the sequence has already been created.
[AUTONUMRESET(name|start)] – This will reset the named sequence to the new “start” value. Be careful as setting the start value to a number that has already been used will allow for duplicates with old values. ** See security note below.
[AUTONUMDELETE(name)] – This will remove the named sequence if it exists. If the sequence does not exist this will do nothing. ** See security note below.
[AUTONUMEXISTS(name|yesvalue|novalue)] – This will see if the named sequence already exists. If it does then the “yesvalue” value will be returned. If not then the “novalue” value will be returned.
** For security, AUTONUMRESET and AUTONUMDELETE can only be called by Administrative users.
Our example above demonstrates using the AUTONUM variable in an E-form. It could just as easily be used in workflow. When the PO E-form is submitted it could be routed and during that process the “PONumber” field could be updated to [AUTONUM(PO)] to set its unique PO Number. The up-side to using workflow is that the AUTONUM value is not used until the PO form is saved. When using AUTONUM during the form load then the next value is assigned and used up before the form is saved. This means the user could cancel the form but the AUTONUM value has already been used and is no longer available. If you need the values to remain sequential with as few gaps as possible, use the AUTONUM variable at the latest possible moment in the process to minimize allocating values that won’t be used.
The AUTONUM variable can also be used when making calls to docMgt remotely using the REST interface. Just before the variable is saved into the Record it will be replaced with its sequence number.
Record Types – General (AUTOID)
Easy Development with docMgt REST Helper
External Related Information
What is a Sequence – Wikipedia