Contact TLCC

Changing Replication Settings via LotusScript Click here to see all the Developer/Admin Tips

Date tip published:08/07/2006
Description:A Notes database has numerous settings to control replication. These are viewed using the Notes client by selecting a database and then choosing, File - Replication - Settings. This tip will explain how to use LotusScript and the NotesReplication class to set any of the replication settings for a database.


To learn more about LotusScript in Notes and Domino use the following links:

Beginner LotusScript for Notes Domino 7
Intermediate LotusScript for Notes and Domino 7
Advanced LotusScript for Notes Domino 7
Notes Domino 7 LotusScript Package



Changing Replication Settings via LotusScript


A Notes database has numerous settings to control replication. These are viewed using the Notes client by selecting a database and then choosing, File - Replication - Settings. This tip will explain how to use LotusScript and the NotesReplication class to set any of the replication settings for a database.

There is only one NotesReplication object per database. To get this object use the ReplicationInfo property from the NotesDatabase class:


    Set notesReplication = notesDatabase.ReplicationInfo

      notesReplication is the variable name for the NotesReplication object.

      notesDatabase is the variable name for the NotesDatabase object.

The NotesReplication class has properties for many of the replication settings. See the list of properties below from Domino Designer Help.

It can also be used to set the replication settings on the Advanced tab of the Replication Settings dialog box. These settings control when a particular computer replicates with another named computer. The NotesReplicationEntry class is used to set these settings and is accessed by using the following method:


    Set notesReplicationEntry = notesReplication.GetEntry( source$ , destination$ [ , createflag ] )




Technique - Changing the Replication Settings


The code below will open the test.nsf database on the local computer and toggle the "Temporarily Disable Replication for this Database" setting. Line 6 sets the repInfo variable to the NotesReplication object for this database. The Disabled property is tested on line 7. If the Disabled property is currently TRUE, it is set to FALSE on line 8. If the Disabled property is currently FALSE, it is set to TRUE on line 11. Line 14 saves these settings. Just like a document must be saved to save any changes made in LotusScript, the Replication Settings must also be saved to save changes.

1.Sub Click(Source As Button)
2.  Dim db As NotesDatabase
3.  Set db = New NotesDatabase("", "test.nsf")
4.  Dim repInfo As NotesReplication
5.  If db.IsOpen Then
6.    Set repInfo = db.ReplicationInfo
7.      If repInfo.Disabled = TRUE Then
8.      repInfo.Disabled = FALSE
9.      Msgbox "Replication was disabled, enabling it"
10.    Else
11.      repInfo.Disabled = TRUE
12.      Msgbox "Replication was enabled - disabling it"
13.    End If
14.      repInfo.Save
15.  Else
16.    Msgbox "Bad DB"
17.  End If
18.End Sub





    Syntax from Lotus Domino Designer Help


    The following table shows the full reference syntax of the NotesReplication class.

    NotesReplication
    NotesReplication Class


    Represents the replication settings of a database.

    Note This class is new with Release 5.

    Containment

    Contained by: NotesDatabase
    Contains: NotesReplicationEntry

    Properties

    Abstract
    CutoffDate
    CutoffDelete
    CutoffInterval
    Disabled
    DontSendLocalSecurityUpdates
    IgnoreDeletes
    IgnoreDestDeletes
    Priority

    Methods

    ClearHistory
    GetEntry
    Reset
    Save

    Creation

    Each database object has exactly one associated NotesReplication object. Use the ReplicationInfo property in NotesDatabase to get the Replication object. Use this object to access and change the replication settings of a database.

    Usage

    After setting a read-write property, you must call Save for the changes to take effect. If you do not call Save, your changes are lost.