I would like to force a database to open locally. The database is opend from a databaselink i another database. The local database has a replicacopy on the server - and I can control wich database to open. I would like to force the local datbase to open.
Subject: Do it at the View -Force DB to open local
The order of events when opening a database (with a default view) is that the View’s events fire first and then the database. After successfully coming up with several scripts that would crash the Notes client every time at the DB level, I switched to the View level and found something that works. Now I will need to add this to all views or change the initial UI to a frameset with a set view that has the code.
Code:
'Notes Objects
Dim WS As NotesUIWorkspace
Dim UIDB As NotesUIDatabase
Dim CurrDB As NotesDatabase
Dim PostDB As NotesDatabase
Dim Flag As Boolean
'Get Handle to Notes Objects
Set WS = New NotesUIWorkspace
Set UIDB = WS.CurrentDatabase
Set CurrDB = UIDB.Database
'Check server
If CurrDB.Server <> "" Then
'Cannot use msg box - breaks context on next commands
'Msgbox "You are currently working on the server not locally." + Chr(13) + "You will now be switched to local to improve performance." , 0, "Working on wrong copy of application."
'Get handle to local replica using server replica ID and open
Set PostDB = New Notesdatabase("", "")
Flag = PostDB.OpenByReplicaID("", CurrDB.ReplicaID)
'Set bookmark on workspace to local to avoid in future
I know how to trap for not being on server, but I have a very basic set of users who do not use the workspace so they have no way of switching to the local replica. I wanted to provide a programmatic way of doing this. There does not seem to be a method or property of the Workspace or UIDB to do this.