RE: Opening a Frameset as default yet returning to the last used view? Kevin Pettitt 29.Aug.02 01:27 PM a Web browser Domino Designer -- Editor Elements 5.0.5Windows 2000
I'm thinking there are three possibilities, all of which have problems.
First, if you can get the QueryClose event of the Database to work (the one in the Database Script under "Resources...Other" in Designer), that is the most "attractive" at first glance. The script would look like this:
****NOTE: This script DOES NOT WORK*******
Sub Queryclose(Source As Notesuidatabase, Continue As Variant)
Dim ws As New NotesUIWorkspace
Dim Session As New Notessession
Dim CurrentUIView As NotesUIView
Const Profilename$ = "UserHistory" 'this is arbitrary, change it to whatever you like,
'since its just a "name" for the profile document
Dim db As notesdatabase
Dim profile As notesdocument
Set CurrentUIView = ws.CurrentView
Set db = CurrentUIView.view.Parent
Set profile = db.GetProfileDocument ( ProfileName, Session.Username )
If Not Isempty(CurrentUIView.view.Aliases) Then 'View has an alias, so let's use that
Forall Xalias In CurrentUIView.view.Aliases 'Multiple aliases (not likely) would mean using the last one
Call profile.ReplaceItemValue ( "FieldStoringViewName" , Xalias ) 'arbitrary field name
Else 'No alias, use the regular name
Call profile.ReplaceItemValue ( "FieldStoringViewName" , CurrentUIView.View.Name )
Call profile.Save ( True, False )
The problem here is that the WS object doesn't know the "CurrentView" during the Database Queryclose, even when the view is the last thing open before it closes. Even if this could work, the other problem with this is that the event doesn't trigger until all windows of the database are closed. If a document is the last thing that was open, I don't think you can reference the view no matter how hard you try.
Second, you could put a button that users must explicitly click on in order to close the database, make this button appear as a view action, and put my code behind the button. Include additional code that sets a flag in the userprofile document - something like:
ProfileDoc.AllowClose = "Y"
You would then have to add some code to DB Queryclose that would read this flag and if it is "Y", then do nothing, or if it is "N", then stop the close with a "Continue = False" line. This code would kick in if the user tried to do an escape close, or otherwise bypass you new button. Once again if you try to close a Document as your last open window, you won't know what view was just open.
*********** My Recommendation ***************
It all comes back to having some kind of code run each time you open a view. My last suggestion, which might simply ease the pain for users by moving the delay to a more acceptable time, is to run my code in the Queryclose of the view, instead of the postopen