My current challenge is in a field I added to the database that I called "Work Order Number." This field should be derived when the form is created and should be incremented one number greater than the highest work order number in existence in the database.
My approach is to use the @dblookup 'dance' in the initialize function of the workordernumber field involving a view with one column (the work order number column), sorted in descending order.
Once the form successfully loads, I need to save it immediately so that work order number is 'saved.' If someone else goes in and creates a new work order, the numbers would increment correctly.
I am hoping there is a code sample out there somewhere or some documentation that I could use to get a jump start on this. This seems to be a common need for incrementing fields like this. Oh, and this has to work natively and using a browser.
It's a bad idea to save a document as soon as someone starts to compose it. What if they change their mind and decide they didn't need a work order after all?
For a work order system there's no need for the order numbers to be sequential; they only need to be unique. Often, people will ask for sequential numbering because it satisfies their sense of order, not because there's a real operational reason for it (e.g., if it were important to be able to look at the list and see whether one were missing, as when balancing your checkbook). If you can just use @Unique in a "computed for display" field, you'll save yourself a lot of grief.
If the idea is to be able to sort the documents based on when they came in, you can't do that if you save the document immediately when they start to compose it. I can start to compose a work order, save it and then go away for four hours before I come back to complete it. Meanwhile five other people have submitted requests. Should mine list before theirs? Wait to save until the user says they want to save, and sort by the @Created date instead.
If you must have sequential numbers: Much has been written about this subject. There's a list of links on this page (look for the "Sequential Numbers" heading). It's not easy, unless you have only a single replica of your application and can wait to assign the number until the document is saved.
Do you have comments on this Ask the Expert question and response? Let us know.
Dig Deeper on Lotus Notes Domino Formula Language
Related Q&A from Andre Guirard
Learn how you can use LotusScript and OLE to create and populate Microsoft Excel spreadsheets, as well as a little bit about Lotus Symphony. Continue Reading
Discover options you can use if you'd like external users to be able to access a workflow-based Notes Domino application through different ... Continue Reading
Learn why you may receive the error message: "Illegal circular use: Audit Trail" when trying to open Lotus Notes documents that use copied forms. Continue Reading