Consolidated scripts

Consolidated these two scripts:

  1.     get last order reference number (orderType)
  2.     next order reference number

Both scripts get the last reference number of a particular order type.  Since orders are based on a universal data model (i.e. all orders are built on one table) then the Serial Number in the data setup cannot be used.*  The two scripts were created a month apart and each had a slightly different method and handled different use cases.  One handled a UI process (i.e. the user created a new order record) and the other handled scripted processes (order records were created as part of a script).

*This is not entirely true. The presumption of Trayse Inventory is that your company would like to have a readable order number that is prepended with the order type abbreviation AND that these order numbers should be sequential.  That is, purchase orders would have PO10001, PO10002, PO10003, etc. and Sales Orders would have SO10001, SO10002, SO10003, etc.


There is another option, which is to use the serial number feature of the field definition. This would remove sequencing within a given order type.  Instead, order number might be PO10001, EO10002, SO10003, PO10006, EO10004, SO10005, PO10006, etc., or more simply 10001, 10002, 10003, 10004, etc. but among all order types.