Topics

03 Troubleshooting
Client, Designer
Macintosh Platform - Notes AppleScript Support

Programming Notes

All the product classes, that is Database, Document, and so on, are documented in the Lotus Notes Programmer's Guide. Use that documentation to explain what the various object/verb/methods/properties are meant to do. However, there are two basic variations from that LotusScript definition you need to know:


AS Objects and their life cycle

The objects created when interacting with Notes are "bridge" objects. They are references to the internal product classes associated with internal Notes programming. When you create an object using the "make new" command or a "get" command from another object, an intermediate object is created to represent that class.

The following script creates an object for the document collection and an object for each of the documents in the collection:
tell app "notes"
set myDB to make new database with data {srvrName, dbName}
openmail myDB
set docCollection to ftsearchdatabase of myDB query "test" maxdocs 3
set aDoc to getfirstdocument of docCollection
repeat until aDoc is equal to 0
set aDoc to getnextdocument of docCollection document aDoc
end repeat

The best approach to deal with these left over objects is to delete them as you go. This approach becomes more critical when your script runs for a long time. For example, as in the case of a script with an idle loop handler:
repeat until aDoc is equal to 0
set aDoc to getnextdocument of docCollection document aDoc
delete aDoc
end repeat
delete docCollection

Alternatively, the command, "flush bridge", can be used at the end of your script. Just make sure that you are no longer planning to use the identifiers, that is, myDB.

The "delete docCollection" line will NOT delete each of the corresponding document objects. If you were looking for a specific document and have attached the document to an AS variable (in this case, the aDoc), that reference will remain after deleting the collection.

Creating Notes product objects

Each object class that can be instantiated as needed will show required/optional parameters in the dictionary class definition.
Class database : make new database with data { server, file }

For the "make new" verb only, the variable identifiers are not included, only the data.
set myDB to make new database with data { "", "mymail.nsf"}

The preceding syntax creates an object that points to the db mymail.nsf in your notes data folder. To open that database, you can either use the normal "open" verb or the Notes-specific "opendb". Each requires that the server/file name be supplied.
open myDB
or
open myDB server "" file "mymail.nsf"


Support of Required/Standard Suite verbs

The ability to use the standard verbs is supported in some cases. In the database open example previously provided, the open verb is supported.
Get/Set/Make are fully supported. Open/print is supported on some objects as relevant.

Note: To see if the command is supported, you should try it in a test.

Default Objects and Order of Precedence

Three suites are considered to be the default objects, Default Notes Suite, Session, and UIWorkspace. By making them application default objects, you do not need to explicitly define them as command targets. Should there be a name conflict between the three default objects, the order of precedence is Default, Session, UIWorkspace.

Note: By design, naming conflicts have been eliminated and therefore occurrence of such conflicts is highly unlikely.

Conceptually, the way to communicate with the uiworkspace would be:
tell app "Notes"
set ws to make new uiworkspace
set aUIDB to get currentuidatabase of ws
end tell

In practice, the creation of the session and/or uiworkspace can be skipped:
tell app "Notes"
set aUIDB to get currentuidatabase
end tell

Boolean var types

When a boolean type is listed in the dictionary as a small integer, you can use the form "with" to specify that var. For example,
getenvironmentvalue varname "DEBUG_CONSOLE" with issystemvar
getenvironmentvalue varname "DEBUG_CONSOLE" without issystemvar

...instead of:

getenvironmentvalue varname "DEBUG_CONSOLE" issystemvar 1