Hi,
I am making an application that requires an autonumbering of documents (I need this at a company Code [char4] and Year level). I have gone through both Domino 4 & 5 and Domino 6 forums post regarding this topic.
I was more or less convinced that the method to adopt was through Lotusscript. Most of the posts that I found suggested the same.
Also I am puzzled about the fact that none of the solutions offered used the Lock method of the Notesdocument class. ( i.e. use a control document and lock unlock it )
Has anybody used the Lock, unlock mehods for this purpose ?.
regards,
Kevin
Subject: RE: Sequential Numbering (Again !)
Locking is more than you need for this. It hurts performance without adding functionality.
To lock, change, and unlock a document, you’re modifying it three times. You’re saving extra information that you don’t really need.
If you load the document into memory without locking it, and change it, and try to save with save conflict detection enabled (False, False, True), most times you are only changing the document once. If the save fails (because someone else beat you to it), use Delete to get the document out of your local cache, reload it, recalculate your serial number and try again. Odds are greatly against three failures, so you’re better off for performance.
A provisional lock is no use for your purposes. You have to do things on the master server or you could be assigning the same ID twice. So the master server must be available. In that case, you might just as well access the document directly on that server using Save as described above.
A danger with locking an important document, is that the user might have a computer crash and leave the document locked. Since one has to lock this document to save a form, nobody can create new forms until an administrator unlocks the document.
Subject: RE: Sequential Numbering (Again !)
Hi Andre,
Thanks for the response.
A few clarification points.
-
I require this sequential numbering feature for a workflow application (We are using Lotus Workflow 3.1).
-
My users are always going to access the Server via the web browser.
-
So my lock - unlock code will run entirely on the server. and that too it will happen when the user ‘completes’ a particular activity. (If a lock fails I pick up the document again (refresh of doc values) and proceed)
-
For now it will always be one server
My problem with using the ‘check for save’ approach is that If two people are reading tha same control document, then they will get the same last number. Then when the save (with the incremented number) is attempted one will go through and the other will wait till the first is finished. subsequently the second save will go thru’(I have put a 5 times retry). The result being that both get the same number.
In view of the above clarification points mentioned above, in your opinion is it still not worth using this approach? I would like some opinions of this approach as I am fairly new to Domino (approx 3 to 4 months).
Thanks again and regards,
Kevin
Subject: RE: Sequential Numbering (Again !)
You write:My problem with using the ‘check for save’ approach is that If two people are reading tha same control document, then they will get the same last number.
Please re-read my previous post – I addressed this.
Subject: RE: Sequential Numbering (Again !)
Hi,
Forgot to ask…
Will the locking and unlocking cause a problem with the control document size. Currently in testing approximately 40 ‘hits’ on a document caused its size to increase from 67 bytes to 393 bytes. Is there anyway I can prevent this from happening.
regards,
Kevin
Subject: RE: Sequential Numbering (Again !)
Maybe http://www.xetrion.com can help you.
Subject: RE: Sequential Numbering (Again !)
Andre,
I’m new to the sequential numbering game and had come up with the scheme where you read the last doc in a view to see the last number used etc. I was running into the scenario where I was seeing occasional duplicated created. I was searchin for a solution when I ran across your post where you describe using the save with conflict detection method and that sounds exactly like what I need. I was just a little in dought of the whole code syntax picture and was wondering would you have a small code snippet that you wouldn’t mind sharing. I would be greatly appreciative. Thanks.
Subject: Try something like:
For i = 1 to 100set NumDoc = NumView.GetFirstDocument
NTU = NumDoc.NextNumber(0)
NumDoc.NextNumber = NTU + 1
If NumDoc.Save(False, False) Then
Exit For
Else
Set NumDoc = Nothing
End If
Next
YourDoc.SequentialNumber = NTU
Subject: RE: Try something like:
Thanks Bill, I’ll try your suggestion.
Any danger of entering and infinite loop with something like this? I wasn’t sure if I should sleep 1 second between iterations and then only iterate the loop for something like 5 times just to prevent an infinite loop scenario. I’ve seen an example where they use a messagebox function to interact with the user and break the loop if necessary, but my code needs to work on the web as well as the client so I don’t think that will work, besides my users would panic if they saw a message box telling them there was an error while trying to generate the number.
Subject: RE: Try something like:
Bill, never mind my last question, I saw you’re only iterating for 100 times then ending the for loop. I haven’t had my coffee yet. My apologies for being obtuse.
Thanks again.
Mark