Object reference variables are used to manage and manipulate objects contained within the Notes applications. There are essentially three steps required to manage an objectdeclare a variable for the object, associate the variable with the object, and utilize methods and properties to manage the object.
For example, in most cases when working with LotusScript, you'll need to define an object variable that refers to the current database. First, declare the variable using the DIM statement. In Notes development, the database object variable is often named db.
Next, use the SET statement to assign a value to the database variable (e.g., associate mydemo.nsf with the object db). Now you can use the methods and properties associated with the NotesDatabase class to manage the database. In this case, the title property returns the name of the database. When used with the Messagebox statement, this example will display a popup message with the database name.
' --- Declare the variable "db" Dim db As NotesDatabase ' --- Associate "mydemo.nsf" with "db" for the current ' --- computer. The "" signifies the current computer which ' --- could be local or on the server. Set db = New NotesDatabase("", "mydemo.nsf") ' --- Display the database name using the "Title" property Messagebox(db.Title)
Besides working with database objects, you may need to work with document objects (e.g., fields). These objects can be referenced from both the front-end and back-end. To access document objects, you again have to declare a variable and associate an object with the variable before you can manage the object.
This second example illustrates the general process for referencing fields. In many cases, you'll need to use the following statements to reference and work with objects from within the document. These statements are often added to action buttons and document events. Although the process is similar to the database object example, the path to referencing the object is more complex because you have to reference other objects before you get to the form objects.
First, you must declare a variable that refers to the current workspace (w), a variable that refers to the front-end object (uidoc), and one that refers to the back-end object (doc). Next, you must set the front-end variable before setting the back-end variable. Finally, you can manage the document or field objects using methods and properties.
Dim w As New NotesUIWorkspace ' Declare workspace variable Dim uidoc As NotesUIDocument ' Declare front-end document Dim doc As NotesDocument ' Declare back-end document Set uidoc = w.CurrentDocument ' Access front-end object Set doc = uidoc.Document ' Access back-end object doc.Status = "New" ' Set field value doc.Save (True, True) ' Save document Call uidoc.Refresh ' Refresh display
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?