Our Blog

The following LotusScript code will show a prompt to users attempting to open a Lotus Notes database in a server that is not supposed to be opened, and automatically redirect them to the new server. The code should be placed in the PostOpen event of the Lotus Notes Database.

 

Sub Postopen(Source As Notesuidatabase)
Dim ws As New NotesUIWorkspace
Dim uidb As NotesUIDatabase
Dim db As NotesDatabase
Dim nnam As NotesName
Dim strOldServer As String
Dim strNewServer As String
Dim strPath As String
Dim strMacro As String
Dim varMacroResult As Variant
Dim intAnswer As Integer
Set db = Source.Database
Set nnam = New NotesName(db.Server)
strOldServer = “OldServer/Org” ‘ADD YOUR OLD SERVER HERE
strNewServer = “NewServer/Org” ‘ADD YOUR NEW SERVER HERE
strPath = db.Filepath
If nnam.Abbreviated <> strOldServer Then
Exit Sub
Else
Print “Opened the database [” + db.Title + “] (” + strPath + “) on the deprecated server ” + nnam.Abbreviated
End If
intAnswer = MessageBox(“IMPORTANT: The database server you are trying to open is obsolete and may contain archived data only.” + Chr(13) + _
“All applications should be used on the server ” + strNewServer + ” instead of ” + strOldServer + Chr(13) + _
“Do you want to be automatically redirected to [” + db.Title + “] in the new server replica if this database is available there?” + Chr(13) + _
“(Click YES to start using the correct server, or NO to keep using the deprecated server)”, _
4 + 32)
If intAnswer = 6 Then
strMacro = |@Command([FileDatabaseRemove]) |
varMacroResult = Evaluate(strMacro)
Call Source.Close()
Call ws.Opendatabase(strNewServer, strPath)
Print “Database [” + db.Title + “] (” + strPath + “) successfully redirected to the new server ” + strNewServer
Else
Print “Operation aborted by the user”
End If
End Sub

Bruno Grange

A passionate by software and a business enthusiast. Check out more about me at http://www.brunogrange.com

  • richa singh

    may i know where i can write this code