Setting up a replica on local

Hi,My user in a different country says that some functionality I built for them works a lot faster with a local replica of our ‘Directory Services’ database, after I suggested they create a local to solve the performance issues.

But…now they want a nice button in email kind of way to create it, which does seem quite reasonable, who wants there user to have to enter a selection formula.

So…

I realised a nice easy way to create a replica stub…

  1. Create Local Replica with Send and Receive documents unchecked;

  2. Now I have a replica stub I can easily get on there workspace, just detach the .nsf file from an email and add the icon…

But…now I want to use the replica I created…I want to:

  1. Set the Replication Formula

  2. Ideally then, Replicate.

So I am trying to do 3) at the moment, using some LS I found on the forum. Its strange, debugging it everything is getting set correctly, and usually no error message occours (e.g. when not debugging), but when debugging the last save line is giving “Error accessing product object method”.

I’d ideally like to avoid scary API calls if possible, I like to keep it quite simple so I understand it…

One thought that does occour is, that maybe it doesnt work because it’s a stub? If so…then how can I create a local database with no documents in (thats the whole point, I don’t want to try and create a local with all documents even as part of the process, as this will be and is incredibly slow)

Here is the code; any ideas?

Sub Click(Source As Button)

Dim repDetails As NotesReplication

Dim repEntry As NotesReplicationEntry

Dim nc As NotesNoteCollection

Dim destDb As New NotesDatabase(“”,“”)

Dim noteId As String

Dim nextNoteID As String

Dim i As Integer

Dim repDoc As NotesDocument

Dim formulaChg As String

'// Get the database some how …

Call destDb .Open( “”, “dir.nsf” )

'// Get the replication settings

Set repDetails = destDb.ReplicationInfo

'// Get the replication details

Set nc = destDb.CreateNoteCollection(False)

nc.SelectReplicationFormulas = True

Call nc.BuildCollection

'// Step through the found design notes and get the associated replication entry

noteID = nc.GetFirstNoteId

'For i = 1 To nc.Count

nextNoteID = nc.GetNextNoteId(noteID)

Set repDoc = destDb.GetDocumentByID(noteID)

'// Get the notes replication entry

Set repEntry = repDetails.GetEntry(repDoc.GetItemValue(“$ReplSrcServers”)(0), repDoc.GetItemValue(“$TITLE”)(0), False)

formulaChg=|SELECT ("Select @Contains(CountryCode;“GB”:“IE”)|

repEntry.Formula = formulaChg

Call repEntry.Save

Call repDetails.Save

End Sub

Subject: Setting up a replica on local.

with Send and Receive documents unchecked are you getting a true stub, which would also have no design elements? Or are you getting an empty replica? And do you then just attach the db to an e-mail with a button in it to detach the db to the user’s PC? If this is the case you could just create a local replica on your PC with a selective replication formula of “SELECT 0”. This will give you a db replica with full design but no documents. Now just change your selective replication formula on that db to whatever you want. Now you can place that in a memo with a button to detach it to the user’s PC and kick off a replication. Does that work for you?

Subject: RE: Setting up a replica on local.

Hi Paul,Well…Yes and No…

Like, Its a good idea to create an empty local replica…I guess if the ‘stub’ was the problem that would have got round it…

But…still the code never works to set the selective replication formula: always no error in the client without Debugger on, and the same one as I put in my original post with the Debugger on…

But no in the sense that, the only way of extending what you are saying is simply for me to create all the local replicas for all countries with the formulas already in…I was hoping for something a bit smarter and more durable than that…it would mean creating distributing and maintaining 17 different LN replicas…maybe that would be OK if people just used 'em straightaway but…what if they only decide to use them in like a year or something, and these ones would have all sorts of horrible documents in them perhaps, or old design elements…etc

Subject: RE: Setting up a replica on local.

Just for a test I created a local replica without copying the ACL.I’m in there as Person Manager with everything ticked and all roles.

Still the code I posted does nothing. It never sets the replication formula at all. Unless you debug no error is experienced either.

Subject: Setting up a replica on local.

Be aware that there is not currently a way via Lotuscript to ensure that the database icon is added to the replicator page - meaning that when you do create the replica, it may never replicate.

There is also no way to remove the database icon from the replicator page.

Just something to be aware of.