SERVICE
This class is a "service" and it is automatically injected if declared as a member in the constructor of the consuming class.
- See the constructor section below for details
- See the Automatic Instance Injection page for details on the topic
The DocumentSeriesService class provides methods to consume local (on-device) document series. The document series feature allows the developer to generate unique number sequences as needed, where the actual format of the number sequences can be controlled by the system administrator. This feature is used in functionalities like invoice and order number generation as well as any other document number generation scenarios, where each document type must have separate number sequence.
Don't instantiate directly instances of the DocumentSeriesService class.
DocumentSeriesService instances are automatically injected by Dynamics Mobile framework.
import {View, DocumentSeriesService} from'$dms';@View()exportclassMyView {constructor(//we need to only declare the memberprivate DocumentSeriesService:ContextService ){ }asyncload(){ //we can now use the injected instance let value =awaitthis.DocumentSeriesService.getCurrentNumber(0); }}
getNextNumber method return the next number for a given document series, uniquely defined by the documentType argument. Note that calling getNextNumber multiple times with the same value for documentType argument, will return the same value always, unless incrementNumber method is called
documentType: number
integer value uniquely identifying the document type for which the next value must be obtained
Returns string value representing the next number for the given documentType
ncrementNumber method return the next number for a given document series uniquely defined by the documentType argument and persists the new value, e.g. making it current.
Note that calling incrementNumber multiple times with the same value for documentType argument, will return different value (incremental) every time.
documentType: number - integer value uniquely identifying the document type for which the value must be incremented
Returns the next number for a given document series, uniquely defined by the documentType argument.
import { View, DocumentSeriesService, UserInterfaceService } from'@dms';import { Invoice } from'@dms-bo';// it is supposed that there is defined business object Invoice in the Business Object folder@View()exportclassMyView {constructor(private DocumentSeriesService:DocumentSeriesService,private UserInterfaceService:UserInterfaceService){ }createInvoice=async ()=>{ //create new document var document =newInvoice(); //get tne next number for displaying purposesdocument.No =awaitthis.DocumentSeriesService.getNextNumber(0);this.UserInterfaceService.showMessage(`The new document number will be ${document.No}`); //expected to show 1 //persist increased document number and persist documentdocument.no =awaitthis.DocumentSeriesService.increaseNumber(0);//persist document in the local device databaseawaitdocument.add();//show the new number on the screenthis.UserInterfaceService.showMessage(`The new document number is ${document.No}`); //expected to show 1 var newDocNo =awaitthis.DocumentSeriesService.getNextNumber(0);console.log(newDocNo); //expected to show 2, because method increaseNumber was called before }