Subject: Lotus Script / What are “session” “workspace” “db”
The NotesSession is the root class for all back-end Notes objects. If you don’t need to use any back-end objects (such as getting the current database without having a UI access method) or can access the back-end objects via the UI (such as using Source.Document in a form event), then you don’t need the session object.
The NotesUIWorkspace is the foundation object for the front-end (UI) Notes objects. If you need to access the UI and aren’t given a built-in hook (like the Source As NotesUIDocument hook in form events), then you need to create a workspace object as a context to get the objects you are looking for.
In the snippet you posted, you probably don’t need either the session or the database objects, since you are likely working only with the current document:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument 'gets a handle to the open UI document
Set doc = uidoc.Document 'gets a handle to the back-end document
'code here can access, modify and save the uidoc or the back end doc
End Sub
If you were doing exactly the same thing in a form event, you wouldn’t necessarily need the workspace either:
Sub QuerySave(Source As NotesUIDocument, Continue As Variant)
'there is already a handle called Source that is equivalent to
'workspace.CurrentDocument
Dim doc As NotesDocument
Set doc = Source.Document
'code here
End Sub
If you need to access something else in the database, like a view or another document, then you would need to create a handle to the database.