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.

This was last published in July 2005

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close