Opening a database on a server with a replicaID when using LotusScript
Problem:
LotusScript does not provide a method to open a database on a server with the replicaID. You must know the name and path of the file where the database is. However, in a large international organization you may not always have control of the path to the database on other servers, making the only reliable information you have the replica id.
Solution:
The script can be placed in the script library or used in situ to provide a handle on the database object, if you can provide the server where the database is and the replica id.
' Written by Kevin Rourke of JacTec Consultancy ' Code used to return a notes database object representing the database with the ' replicaid and on the server passed to the function ' Nothing is returned if the database cannot be found ' Calling code and useful code ' ************************************ %REM ' this code finds a database on the same server as the current database ' and opens it allowing access to it's objects Dim session As New notessession Set db = session.currentdatabase Set anotherdb = FindDatabaseObject(db.server, replicaid) Call anotherdb.Open( "", "" ) %END REM Dim db As notesdatabase Dim anotherdb As notesdatabase Dim ndb As notesdatabase Function FindDatabaseObject (servername As String, dbreplicaid As String) As notesdatabase Dim dbdir As New NotesDbDirectory(servername ) Set ndb = dbdir.getfirstdatabase(database) Print "Searching for database on " & servername While Not ndb Is Nothing If ndb.replicaid = dbreplicaid Then Set FindDatabaseObject = ndb Print "Found database " & ndb.title & "on " & servername End If Set ndb = dbdir.getnextdatabase Wend Print "Database cannot be found on server " & servername Set FindDatabaseObject = Nothingbye End Function