#055 BC NUMBER SEQUENCE DATA TYPE

NumberSequence is a new Business Central Data Type for creating and managing number sequences in the database.

They are built on SQL Server sequences, meaning that they are not associated with any tables. The numbers in a number sequence are generated in ascending order at a defined interval but can be skipped.

In some cases, the use of NumberSequence may constitute an advantage over No. Series, as it allows to implement non-continuous and non-blocking numbering with simplicity.

 

The following methods are available on the NumberSequence data type:

  • Insert(Text [, BigInteger] [, BigInteger] [, Boolean]) – Creates the number sequence
  • Exists(Text [, Boolean]) – Checks the existence of a specific number sequence
  • Delete(Text [, Boolean]) – Deletes a specific number sequence
  • Current(Text [,Boolean]) – Gets the current value from the number sequence
  • Next(Text [, Boolean]) – Gets the next value from the number sequence and increments its value
  • Range(Text, Integer, var BigInteger [, Boolean]) – Retrieves a range of values from the number sequence
  • Restart(Text [, BigInteger] [, Boolean]) – Restarts the number sequence

 

Example

Scenario: Imagine that for every newly created Customer Bank Account associated with a Customer (with Customer No. ‘CUST1’), it is necessary to have an identifier that represents the order of creation.

 

Firstly, the NumberSequence is initialized in the insertion of the Customer.

#055 BC NUMBER SEQUENCE DATA TYPE | Arquiconsult - Soluções Microsoft Dynamics 365: Arquiconsult é uma empresa Consultora de Sistemas de Informação - 77600

Then, every time that a Customer Bank Account is created for customer ‘CUST1’, the next value from the number sequence is retrieved and attributed to the field OrderOfCreation.

#055 BC NUMBER SEQUENCE DATA TYPE | Arquiconsult - Soluções Microsoft Dynamics 365: Arquiconsult é uma empresa Consultora de Sistemas de Informação - 77600

Finally, if the Customer is deleted, the associated NumberSequence should be deleted alongside it.

#055 BC NUMBER SEQUENCE DATA TYPE | Arquiconsult - Soluções Microsoft Dynamics 365: Arquiconsult é uma empresa Consultora de Sistemas de Informação - 77600