Function DbCreateReplica(s As NotesSession, sDb As NotesDatabase, tserver As String, ftcreate as Integer) As Integer ' checks for existing replica on target server, if not found, creates replica on destination server ' sDb - source application to create replica from ' tserver - name of target server on which to create new replica (should be a common name or full canonical one) ' ftcreate - toggle to force create index even if one doesn't exist on source one Dim tDb As NotesDatabase ' target replica of sDb being created (if not already existing) On Error Goto FErrorHandler ' do tests and open If (sDb Is Nothing) Then DbCreateReplica=0 Exit Function End If If Not (sDb.IsOpen) Then ' should not be open, as DbDir does not open dbs, this call can crash if agent signer cannot open this db Call sDb.Open("","") If Not (sDb.IsOpen) Then ' give up, prompt user to note current database Print "Unable to open database: " & sDb.FilePath & ". You need to write this path down and manually replicate it." DbCreateReplica=0 Exit Function End If End If ' database should be open, check for replica already on target Set tDb = New NotesDatabase("","") If (tDb.OpenByReplicaID(tserver, sDb.ReplicaID)) Then ' database exists already, check if filepath is same If Not (Strcompare(sDb.FilePath, tDb.FilePath, 5)=0 ) Then ' filepaths are same, done Print "Database, " & sDb.FilePath & ", already has replica in same location on target server." Else ' filepaths not the same, display to user to review and address as needed Print "Database, " & sDb.FilePath & ", already has replica in on target server, but in different location, " & tDb.FilePath & ". Skipping this application. Please remove the other and re-run or create manually." End If Else ' database does not yet exist, which is fine, we will create the replica now (assuming have rights to do so on server doc) Set tDb = sDb.CreateReplica(tserver, sDb.FilePath) End If ' check for fulltext index and create if existing If (ftcreate=1) Then ' create full-text index on new server replica Call tDb.CreateFTIndex(FTINDEX_ATTACHED_FILES + FTINDEX_ATTACHED_BIN_FILES + FTINDEX_ENCRYPTED_FIELDS, True) Else ' create only if source application had an index If (sDb.IsFTIndexed) Then ' create index for tDb Call tDb.CreateFTIndex(FTINDEX_ATTACHED_FILES + FTINDEX_ATTACHED_BIN_FILES + FTINDEX_ENCRYPTED_FIELDS, True) End If End If ' done DbCreateReplica=1 ResumeExit: Exit Function FErrorHandler: Print "Unexpected error creating replica database: " & sDb.FilePath & ". (Error: " & Cstr(Erl) & ", " & Error$ & ") You need to write this path down and manually replicate it." DbCreateReplica=0 Exit Function End Function