There are two ways to access data from a document in LotusScript. The first is through something called the Extended Syntax and the second is through the GetItemValue method in the NotesDocument class. From a performance standpoint, both methods take a similar amount of time. However, there might be other reasons for choosing one over the other.
The extended syntax is a way to directly access a field by its name. For example, to read the value of the “form” field off a document, the following statement uses the extended syntax:
The GetItemValue method takes a parameter of the field name. It returns an array of values where the data type of each value depends on the data type stored in the document. Many developers will quickly access the first value of the array in their code. For example, the two code blocks below return the first value of the “Form” field off the document:
result = doc.GetItemValue("Form")(0)
resultArray = doc.GetItemValue("Form")
result = resultArray(0)
Comparing extended syntax to GetItemValue
The performance comparing GetItemValue and the Extended Syntax is nearly identical. Choosing which method to use comes mainly down to personal preference.
The major advantage to using the extended syntax is the number of keystrokes required to enter in the statement. Although, with type-ahead available in Domino Designer, the GetItemValue method can be automatically completed for you in a few key strokes.
One disadvantage to using the extended syntax is using a field name that might, in a future release, become a method or property name. For example, the MarkRead method was introduced in Domino 8 Designer. If your code previously accessed a field called MarkRead with the extended syntax, that would no longer work on a Domino 8 client or server.
One advantage to using the GetItemValue method is portability to Java.
Avoid Opening Notes Unnecessarily
When processing documents obtained from a view (either by a key search or by iterating through the view) it is more efficient to access information about the document using the NotesDocument.Columnvalues or NotesViewEntry.Columnvalues property rather than referring to a field directly. Column information can be obtained from the stored view index, without having to access the note data, so it is faster.
Parent topic: 6.0 Performance considerations