Limit the Ability to Create Documents on a Local Database
As a Domino developer, you may find the need to limit the ability to create documents in a local replica of a database. For example, if the Notes application automatically assigns sequential document numbers as new documents are created and users are permitted to create documents in local replicas, then it's possible that the same document number could be assigned to multiple documents. One solution is to restrict the ability to create new documents on the local database.
How It Works
The QueryOpen event is triggered as documents are about to be displayed in the Lotus Notes user interface. Here, you can check the state of the document (e.g., new or existing document) as well as the location of the database (e.g., local or server). The combination of these two values enables you to limit the creation of documents.
First, the routine determines whether the document is new or preexisting using the IsNewDoc function. If the document already exists in the database, a FALSE value is returned and processing continues. Otherwise, a trUE value is returned. This indicates that a new document is about to be created via the user interface, and an additional validation check is performed.
To determine whether the document is on the server, the LotusScript code checks the Server property for the database object. If this property is empty, a local database is being used. When the database is a local instance, a warning message is displayed and processing stops. Otherwise, the database resides on the server and processing continues.
Note
This solution limits the ability to create new documents via the user interface. Depending on the database design and user skill level, a Notes-savvy person may still be able to create a new document through back-end programming.
Implementation
To implement this solution, insert the following code in the QueryOpen event for a given form.
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant) Dim s As NotesSession Dim db As NotesDatabase Set s = New NotesSession Set db = s.CurrentDatabase Continue = True If source.IsNewDoc Then If db.Server = "" Then '-------------------------------------------- ' Local instance halt processing '-------------------------------------------- Msgbox "New documents must be created "+_ "on the server.", 16, "Local Database" continue = False Else '-------------------------------------------- ' Server instance continue processing '-------------------------------------------- ' Msgbox "Database resides on a server." End If End If End Sub