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


An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management

Security

Application Deployment and Maintenance

Troubleshooting

Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?

show all menu





Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net