This simple script is used for generating sequential numbering of fields in the document. First, create a field SequenceNo. It should be Editable, Number. Then, add the script below in QuerySave subfunction of Main Document.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Dim doc As NotesDocument Dim tmpSeqNo As Variant Dim NxtSeqNo As Variant Set collection = db.AllDocuments Set doc = collection.GetLastDocument If source.IsNewDoc Then tmpSeqNo = doc.GetItemValue ("SequenceNo") If Isnumeric(tmpSeqNo(0)) Then NxtSeqNo = tmpSeqNo(0) + 1 End If NxtSeqNo = Cstr(NxtSeqNo) Call Source.FieldSetText ("SequenceNo", NxtSeqNo) End If
I think this tip is something that you should NOT use ,since this will not work properly in a replicated environment. It will (at least theoretically) be possible for conflicts to occur in a heavy multi-user environment or, even worse, two documents could be assigned the same "sequential" number before the backend document is updated.
I strongly advice that if you really want to use sequential numbering in your application, please read this Notes.net technical article.
This tip doesn't work correctly when you have replicas on other servers or more than one user who worked with this database at the same time.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Girlie Berou. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.