Manage Learn to apply best practices and optimize your operations.

Sequential numbers using LotusScript

This script is used for generating sequential numbering of fields in the document.

View member feedback to this tip.

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.

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
  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 technical article.

—Kenneth A.


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 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.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...