Link to home
Start Free TrialLog in
Avatar of shals0628
shals0628

asked on

How to main the sequentially generated numbers for each document when Replication is enabled usin Lotus Script?

Hi,

Current Scenario is - When a document is created, a number is assigned to that particular document. This is incremented sequentially as and when users created documents on Production. Issue faced, is when Replication is enabled, there is a duplication of these sequentially generated numbers. How do we maintain them unique when Replication is being used? Please help.
Avatar of SysExpert
SysExpert
Flag of Israel image

A great link! My advice:
- don't rely on sequential numbering in Notes... never!
- look for alternatives
- can you use @Unique to produce a unique key?
- last resort: use system-wide locks (could be a disaster for the performance)
Another option if you need to work with existing numbering and if the numbers don't have to be immediately available:

. Create the document without a number
. Create a view to display documents without numbers, sorted in created order, ascending
. Create a scheduled agent to assign numbers - schedule it to run overnight
Avatar of RonaldZaal
RonaldZaal

We do numbering on multiple db's without problems when using the following setup
- create a profile document for the db, in a field you define a "Main" server
- when a document is created and saved for the first time you check the server and if it is the main calculate or lookup the new number in the querysave of the document
- at night an agent runs on the documents which are not created on the main server to populate the number

Agree with SJef to find alternatives to Sequential numbesr but it seems that some people just love to have them nice and neatly ordered no matter what the designers/admins say :)

Depending on your connectivity to servers and how often new docs are created compared to just edits.

If you are using a field and @dblookup or @DBcolumn then make it pick from a specific server and database rather than null values from current database. also form should save doc immediately once number allocated.
If value/formula  is @error then create a local random ID that agent picks up on central server once every x minutes/hours.
Have a check for duplicates and inform an admin once a day etc.

Sort of combining the above into one solution that covers most times they absolutely insist a document is sequential and generally when creating documents is not as heavy as editing etc.
Avatar of shals0628

ASKER

@All - Thanks.

@Sjef - @unique I can propose, but what about the existing documents? As doninja says, people do love sequential numbers!!!

Let me explain you the current working.

A Hidden View is present where action button is available to create a form only to enter a 'Record Number'.  The Admin will create the document and enter the value in Record Number (start point for sequential number)

Once creates document completes all data in the form and click on 'Save and Close' - Script Library is called in which one sub function is called to assign the Number. The code for the same is as below:

Sub AssignChkNo(uidoc As NotesUIDocument)
      
      Dim recordvw As Notesview
      Dim profdoc As NotesDocument
      
      If uidoc.IsNewDoc Then
            Set recordvw = db.GetView("(Record Number)")
            Call recordvw.Refresh
            Set profdoc = recordvw.GetFirstDocument
            childnumber = profdoc.Checknumber(0)
            chkdoc.LogNo = childnumber +1            
            profdoc.Checknumber = childnumber +1
            Call profdoc.Save(1,1)
            Call uidoc.save
      End If
      
      End Sub

Is there a possibility to retain the code and achieve the objective to maintain the uniqueness of this number generation?
To retain the code, use RonaldZaal's suggestion, ie add a check for the designated "Main" server and only add numbers for documents on this server.  Documents created on other replicas to be processed by a scheduled agent outside normal office hours, on the designated "Main" server, to assign numbers.
@RonaldZaal - Can you please help me how to go about the agent? The Db Profile is already set up and the Number is assigned when user creates the document on Server. At least provide me the logic to it.
@Gingerdeb - Thanks to you too.
ASKER CERTIFIED SOLUTION
Avatar of RonaldZaal
RonaldZaal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot !