Sequential Numbers - Multi User System

I’m trying to generate sequential numbers in a multi user environment. I have searched the forums and etc.

I’ve heard the following book is a good resource, Inside LotusScript by Joe McGinn

Any help would be appreciated.

Subject: Keep offline replicas in mind

Some thoughts:- If you want to use sequential numbering it MUST be done though one central server document. If the server document is not reachable, set a temporary number and let a server agent update the document. Otherwise prevent the creation if the central server is not reachable.

  • It’s better to set the number on saving

  • You might also want to check ‘document locking’ in the designer help: If agents need to number the document it’s a good idea to lock the document for the users (especially if working on different servers)

Subject: When do you need the number?

Do you need the number generated on document creation? Save event? Can it be done in a batch type agent at night?

There are a lot of different ways you can do this.

Subject: Its Done…

Right now it is done on creation. The problem with this is that if multiple people create a document they would end up getting saved with the same number. I would like to do it on the save of the document. I think an agent that runs on the server would work.

If an agent runs on a server, do they run concurrently or sequentially ?

Subject: Two problems with your current approach

You say that if multiple people create docs at the same time they end up with the same number. That suggests that you’re getting new numbers via a lookup view that contains a sorted list of all docs already created.

There are two problems with this. As you’ve already found out, it doesn’t handle simultaneous creation well. You would be better using a database-wide profile document that stores the current sequential number (or a regular doc in a hidden lookup view).

Also, the lookup to find the next number in the sequential view may get slower and slower as you add more documents to the database.

Rupert

Subject: Sequential numbering tips from FAQs

As you might imagine, there is a variety of ways to handle this challenge and the question as been answered a lot of times in previous postings.

See

and

http://www.keysolutions.com/NotesFAQ/howdo.html

for various approaches.

Among your considerations here are:

  • Does the application have multiple replicas (or will it in the future)?

  • Do you really need sequential nunbers (as opposed to unique keys such as those generated by @Unique)?

  • If you need sequential numbers, is it a problem if there are gaps in your sequence corresponding to cancelled docs?

  • And so on…

The more of those questions you answer yes to, the more complex your solution needs to be.

Rupert Clayton

Chicago