Document Number Series

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

Features

  • Allows tracking of unlimited number of document types

  • Works with custom

  • Persistent tracking - e.g. persists the tracked numbers in the cloud

  • Management of the Document Number Series by the application area administrator

    • The admin can control the start number, end number and format of the serie for each document type