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
("SequenceNo")
  If Isnumeric(tmpSeqNo(0)) Then
     NxtSeqNo = tmpSeqNo(0) + 1
     End If
  
     NxtSeqNo = Cstr(NxtSeqNo)
     Call Source.FieldSetText 
("SequenceNo", NxtSeqNo)
     End If

MEMBER FEEDBACK TO THIS TIP

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.

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

—Axel

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.

Dig Deeper on LotusScript

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close