Set advanced replication settings via lotusscript

I want to set the advanced replication settings of a database to include the design elements, agents, acl, and deletions.

the simplified code below isn’t able to get a handle on the replication entry:

Option Public

Option Explicit

Sub Initialize

Dim session As New notessession

Dim server_directory As NotesDbDirectory

Dim file As NotesDatabase

Dim rep As NotesReplication

Dim re As NotesReplicationEntry



Set file=session.GetDatabase("servername1/domain", "filename.nsf")

Set rep = file.ReplicationInfo

Set re = rep.GetEntry("servername1/domain", "servername2/domain", False)

re.IsIncludeForms = True

re.IsIncludeAgents = True

re.IsIncludeACL = True

re.IsIncludeDocuments = True

Call re.Save()

End Sub

This is the offending line of code in that in the “variables” tab of the debugger, no value is present:

Set re = rep.GetEntry(“servername1/domain”, “servername2/domain”, False)

I also try:

Set re = rep.GetEntry(“-”, “-”, False)

and:

Set re = rep.GetEntry(“-”, “-”, True)

and no cigar,

any ideas on how to get this thing to work?

thks,

-MC

Subject: set advanced replication settings via lotusscript

probably because the particualr entry you are trying to open does not exist. try changing your create flag to True.

Subject: RE: set advanced replication settings via lotusscript

If I set the create flag to true, a new entry is created which is not associated with the db that the agent has a handle on (the one which I’m trying to modify).

I have tried this with several entries, all of which exist, no cigar.

The fact that this is treated as an “Entry” may be indicative of me not using the correct method. This is not an ACL type situation where you have a list of entries, there is only one area in the advanced replication settings where these parameters are set, I don’t understand why the term “entry” in the first place.

This is simply an attempt to modify the replication settings in Database Properties/Replication Settings/Advanced …

any other ideas?

-MC

Subject: RE: set advanced replication settings via lotusscript

because you can set different entries for different server combinations. When you open the Rep settings dialog box and switch to the advanced tab, at the tops you will see where you can set/delete the server pairs (source,destination). Each server pair is considered an entry.

Subject: RE: set advanced replication settings via lotusscript

then how can I specify for any & all entries present, to do the following …

again the:

Set re = rep.GetEntry(“servername1/domain”, “servername2/domain”, False)

Set re = rep.GetEntry(“servername1/domain”, “-”, False)

Set re = rep.GetEntry(“-”, “-”, False)

doesn’t capture anything,

The following line

Set re = rep.GetEntry(“-”, “-”, True)

attempts to create an entry but that entry doesn’t get saved

any ideas?

thks,

-MC

Option Public

Option Explicit

Sub Initialize

Dim session As New notessession

Dim server_directory As NotesDbDirectory

Dim file As NotesDatabase

Dim rep As NotesReplication

Dim re As NotesReplicationEntry



Set file=session.GetDatabase("servername1/domain", "filename.nsf")

Set rep = file.ReplicationInfo

Set re = rep.GetEntry("servername1/domain", "servername2/domain", False)

re.IsIncludeForms = True

re.IsIncludeAgents = True

re.IsIncludeACL = True

re.IsIncludeDocuments = True

Call re.Save()

    Call rep.Save()

End Sub

Subject: RE: set advanced replication settings via lotusscript

taken from Designer Help db and it works for me:

Sub Initialize

REM Get local database

dbName$ = "testrep.nsf"

Dim db As New NotesDatabase("", dbName$)

Dim rep As NotesReplication

Dim re As NotesReplicationEntry

If Not db.IsOpen Then

	Messagebox "No local database",, dbName$

	Exit Sub

End If

REM Get source and destination computers

source$ = "CN=MAIL01/O=ACME"

destination$ = "CN=MAIL02/O=ACME"

REM Get replication entry

Set rep = db.ReplicationInfo

Set re = rep.GetEntry(source$, destination$, True)

If re Is Nothing Then

	Messagebox _

	"No replication entry for " & source$ & _

	" and " & destination$,, _

	"No such replication entry"

	Exit Sub

End If

REM Toggle property and save entry

If re.IsIncludeForms Then

	re.IsIncludeForms = False

Else

	re.IsIncludeForms = True

End If

Call re.Save()

Messagebox "Is now " & re.IsIncludeForms,, "IsIncludeForms"

End Sub

Subject: RE: set advanced replication settings via lotusscript

source$ is not being declared.

I tried the above code as is and got the “variable not declared” error.

one thing I did try is using GetEntry(“-”, “-”, True) and it does work for (from) -All Servers- (to) -All Servers- but still can’t get this dam thing to work for GetEntry(“CN=server1/O=Domain”, “-”, True)

thanks for all your help tho

-MC

Subject: RE: set advanced replication settings via lotusscript

sorry I cannot be of further assistance because the code I posted works fine for me so I don’t know why it’s not working for you. I’m using 6.5.1 client.

Subject: SOLUTION: set advanced replication settings via lotusscript

GetEntry under ReplicationInfo requires the source, destination, and createifnotalreadythere flag in that order.

What was confusing (to me) is that in the advanced replication settings, the server that the database resides on (the “When Computer”) is the destination and “Receives From” is the source

So I changed:

Set re = rep.GetEntry(“servername/domainname”, “-”, False)

to:

Set re = rep.GetEntry(“-”, “servername/domainname”, False)

and violahh, everything works.

definitely need to send a shout out to Paul who stuck with me through this excruciating process, my full code is below, hope this helps someone,

-MC

Option Public

Option Explicit

Sub Initialize

On Error Resume Next



Dim session As New notessession

Dim server_directory As NotesDbDirectory

Dim file As NotesDatabase

Dim rep As NotesReplication

Dim re As NotesReplicationEntry

Dim server As NotesName



Set file=session.GetDatabase("servername/domainname", "databasename.nsf")

Set rep = file.ReplicationInfo



Set re = rep.GetEntry("-", "servername/domainname", False)



rep.IgnoreDestDeletes = False

re.IsIncludeForms = True

re.IsIncludeAgents = True

re.IsIncludeACL = True



Print "ignore deletes: " + Cstr(rep.IgnoreDeletes)

Print "include forms: " + Cstr(re.IsIncludeForms)

Print "include agents: " + Cstr(re.IsIncludeAgents)

Print "include ACL: " + Cstr(re.IsIncludeACL)



Call re.Save()

Call rep.Save()

End Sub

The code above grabs a database, and sets the advanced replication settings to include delations, the acl, the design elements, and agents.

This is for a single db but upon request I can post the full version which cycles through all mail files on all mail servers

Subject: RE: SOLUTION: set advanced replication settings via lotusscript

Often, one wishes to update all the replication documents. Here’s a little LotusScript program I wrote to do that:

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim db  As NotesDatabase

Dim repLookup As New NotesDatabase( "", "" )

Dim view As NotesView

Dim doc As NotesDocument

Dim rep As NotesReplication

Dim re As NotesReplicationEntry

Dim replicationFormula As String

Dim computers(1 To 5) As String

'set value for replication formula

Set db = session.CurrentDatabase

If db.server <> "" Then

	Messagebox "This is the server copy of the database!  You may only modify the replication formula on the local copy."

	Exit Sub

End If

computers(1) = "-"

computers(2) = "CN=server1/O=ACME LTD"

computers(3) = "CN=server2/O=ACME LTD"

computers(4) = "CN=server3/O=ACME LTD"

computers(5) = session.UserName

Set rep = db.ReplicationInfo

Forall x In computers

	Forall y In computers

		Set re = rep.GetEntry(x, y, False)

		If Not re Is Nothing Then

			re.Formula = replicationFormula

			Call re.save

		End If

	End Forall

End Forall

Messagebox "Your replication formula has been amended"

Subject: RE: SOLUTION: set advanced replication settings via lotusscript

One other thing: one must have manager access to the db to be able to update replication entries programatically. Use the following code:

If db.CurrentAccessLevel < 6 Then

	Messagebox "You do not have sufficient access to this database to be able to change the replication formula programmatically - sorry."

	Exit Sub

End If

Subject: RE: set advanced replication settings via lotusscript

You have “Entries” because these settings relate to a Database-to-Database relationship.

e.g. Database has replicas on Local, Server A and Server B

There might be different Entries for Local<->A and for Local<->B