Tested in Notes R4.63
Sometimes a form contains only a few fields that require user input. Normally,
the user would open documents created with these forms by double-clicking on
them from a view. This would open the document in another window, perhaps full
screen. After editing or viewing, they would close the window, perhaps also
saving their changes, and return to the view.
As an alternative when the user double-clicks on a document, we could open it
in a dialog box allowing the user to edit and save the document, without
opening a new window. This provides the user with a familiar UI experience (a
dialog box) and helps the user maintain their mental "context" at the view
level.
The code is in the view's QueryOpenDocument() event. It has been simplified
here for clarity, but can be enhanced. For example, a view with documents
created with different forms can be selective as to which documents will be
opened in a dialog and which will be opened in the usual way. Also, the code
could be adapted as a Script Library function so that multiple views can have
this functionality, while maintaining the code in one place.
The effect is most pleasing when the form used has the editable fields placed
in a layout region.
Grant Lindsay
Senior Programmer Analyst
Zurich Canada
Sub QueryOpenDocument( Source As NotesUIView, Continue As Variant )
Dim ws As New NotesUIWorkspace
Dim docSelected As NotesDocument
Dim strTitle As String
Dim bDoSave As Integer
' Supress the natural way of opening the document.
Continue = False
' Get a handle on the document the user wants to open.
Set docSelected = Source.Documents.GetFirstDocument()
' Set the dialog's title.
strTitle = "Edit Time Sheet - " & docSelected.ParentDatabase.Title
' Present the Time Sheet and trap user's button choice.
bDoSave = ws.DialogBox( docSelected.Form(0), True, True _
, False, False, False, False, strTitle, docSelected )
' If they pressed 'Ok' then save the document and refresh the view.
If bDoSave Then
' You may put other processing code here...
If docSelected.Save( True, True ) Then Call ws.ViewRefresh()
End If
End Sub
This was first published in November 2000