Document Number Series

document number series to guarantee unique document numbers

Overview

Dynamics Mobile SDK provides API to manage Document Number Series.

Very often when building business applications and design functionality to "generate" business documents like invoices, orders , it is required to be able to "assign" unique number for each of the documents. It is also important that these numbers must be sequential ( not skipped numbers) and have a custom format ( letters, numbers and other characters in certain order),which varies per organization.

The "Document Number Series" API is meant to address these issues. It can be used via the DocumentSeriesService class.

Example

Let us assume the following code:

enum DocumentTypes = {
  Invoice = 1,
  Order = 2,
  ReturnOrder = 3
}

//create instance of Invoice class (extending BusinesObjectBase)
const invoice = new Invoice();
invoice.totalAmount = 999.99;

//obtain the next invoice number.
const nextInvoiceNumber = await this.DocumentSeriesService.incrementNumber(DocumentTypes.Invoice);

//assign the new invoice number to the appropriate business object member 
invoice.DocumentNumber = nextInvoiceNumber;

//save the invoice into the database
await invoice.add();


So the code, creates instance of the Invoice class (line #8), which extends BusinessObjectBase - e.g. it is a business object defined via Business Object Definition. The actual Invoice Business Object Definition is is not given here.

Once the invoice instance is created, it assigns an amount - line #9.

It then calls the method incrementNumber of the DocumentSeriesService instance (line #12) to get the next invoice number. Note that we are providing a number as an argument for method incrementNumber, which defines, which document series to use. We (the developer) in this case decided that we will use 1 as identifier for the Document Number Series for invoices. When we call the incrementNumber with argument 1, it will always increase the number and will return it as a result. The increased number is then automatically synced to the cloud, so even if we "restart" the app, we will get the increased number next time.

Finally we save the invoice into the database - line #18

Setting up

The document series can be configured from the application area.

Login to the application area, open app MOBFL and navigate to menu Setup/Mobile Document Series. There you need to add a new document series setup for each document which numbers you need to track.

Last updated

Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com