Starting with Lotusscript (Part 1)


This document, together with live application development using Lotusscript, is intended to assist the experienced Lotus Notes developer in starting to work with Lotusscript. If you want to know more about object-oriented programming (OOP) concepts, there are legions of links on the web. OOP with Lotusscript specifically is discussed in Bruce Perry's article over at the Lotus Developer Domain.

Lotusscript is a procedural language which complements Notes formula language. For example, script is ideal for iterative processes, such as looping through and editing documents in a view, whilst formula language excels at single-line commands such as @DbLookup. Lotusscript is also broadly compatible with Visual Basic, so functions and code designed for that platform can often be implemented in your Notes applications.

Whilst using this document and coding script, it is useful to make reference to the Lotusscript Object Data Classes model diagram — again, see the Lotus Developer Domain for a copy of this.

It is hoped that this series of small articles will help you 'find your way,' but the emphasis is very much on learning your own method of coding, and going with it. Reading other people's script will provide invaluable guidance.

Getting started: What are classes, objects, properties, etc?

Classes provide the interface in Notes which allows the developer to access and manipulate Notes constructs with Lotusscript. What do I mean by this? Well, you're familiar with the concepts of a database, views, forms and so on — these are all "Notes constructs."

So, classes represent the various elements which make up a Lotus Notes database and environment. The following examples of classes should therefore be familiar:

  • NotesDatabase
  • NotesACL
  • NotesDocument
  • NotesView

Classes have properties and methods, which will be explained later. To give you an idea for now, oft-used properties of the NotesDatabase class include its 'ACL', whether the database is full-text indexed (IsFTIndexed), and so on. Properties can also include lists of things like all the forms or agents in a database (NotesDatabase.Forms & NotesDatabase.Agents, funnily enough).

Methods for the same class include 'Search' and 'Compact.'

"Events" are also crucial to an understanding of script — it is an event-driven language where these events are linked to various Notes objects:

  • The 'click' event in a button object
  • The 'exit' event in a field
  • Various type of events in the agent object
  • The 'querysave' and similar events in the form object

How do I find out about classes and what I can do with them?

The Lotusscript browser is invaluable for both experienced coders, and those new to Lotusscript. The graphic below shows the relevant pane in the IDE:

The reference pane in Domino Designer

You can look at all the classes, functions, etc., and expand these to see their associated properties, methods and events (where applicable). The best feature of the browser however, is that when an item is highlighted in the browser pane, pressing F1 will bring up contextual help for that item (usually. But you probably know the vagaries of Notes help by now…). The help database also includes examples and links to related items. This is extremely useful. Sometimes.

The Lotusscript editor formats and parses everything automatically, so you always know where you are, except that it doesn't feature line numbering (but see later). Saving your script will compile it, and flag any errors occurring (there will be plenty in the early days!) Note that this means the script, if it has errors, will not actually be saved.

If you need to leave your machine and have a coffee or something, you should 'comment out' the offending code, save the now cuddly and inoffensive code, and grab your caffeine fix. See Part 2for clues as to how to do this (comment out, not drink coffee).

Declare everything!

The new Notes 6 Domino Designer Programmers Pane options

Finally, get used to using Option Declare or Option Explicit. These lines in your Lotusscript (Options) pane, are invaluable. They will ensure that every variable and object you wish to use, you declare explicitly up front. This means, hopefully, you'll cut down massively on any Object Variable Not Set errors. This is crucial to any good coding, i can't emphasise that enough… and Lotus seem to think so too, as you can automagically insert Option Declare at the start of any Lotusscript you do, starting with Notes 6. (Hint: look at "Programmer Pane properties" when you're in Domino Designer doing some Lotusscript, and you can bring up the pane shown above).

Part 2 covers documenting your code

Part 3 covers coding error handlers.

Further reading

Comments on this post are now closed.


I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.