Question

  Asked: Jan 21 2008   2:46 AM GMT
  Asked by: 0rland0


codelock function


CodeLock, LotusScript

Can anyone explain the real functionality of this function? Where this function must run? Must in be an agent? I'm trying to solve a number duplication problem.

Any help or suggestions are welcomed. Thanks

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0



HI Orland0,
I use code lock when I need to assign a unique Number to a Notes document Field, e.g. A Purchase Order Number.
So if more than 1 processes are trying to get the next number in a sequence but you do not want then to get the same next number you lock the code so they run one after another therefore reducing the possibility of duplicate numbers.

Note, however, that this only works when the other processes competing to run that code are other threads in the same server process. In other words, it works well if you have no local replicas and it's a Domino web application and is not clustered.

If you do have multiple replicas or you need to support Notes client use, then you need to do something more complicated.

If you have one server and you want to assign the number from a Notes workstation, you can use RunOnServer to cause the agent that assigns the number, to run on the server. Codelock should work in that case (though I haven't tried it).

If you have multiple replicas, and people assigning numbers in all of them, you have a tough situation to prevent duplications. In that case you might either have a unique prefix for each replica, or else have a single shared number server -- this can be done with a web service -- but of course this does not support offline use.

Often, people make things difficult for themselves by insisting on a sequential number. The @Unique function creates an identifier that's almost certain to be unique across all replicas, and it's very, very easy to use.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Lotus Domino.

Looking for relevant Lotus Domino Whitepapers? Visit the SearchDomino.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

0rland0  |   Jan 30 2008  3:39AM GMT

Hi jellybean,

I’ve tried using codelock to do exactly the same thing that you do..but i still get duplicate numbers..
Do you mind if you tell how you go about doing it? Just the structure will be great!..

Thanks for your time ;)