Getting an item and its values in LotusScript® classes

The NotesDocument class provides several properties and methods to access the items in the document. If you do not know the name of an item or want to traverse the items in a document, you can use the Items property, an array of NotesItem objects. As you access each array element, use the NotesItem properties and methods to interrogate and manipulate the object.

To access an item whose name is known, use the GetFirstItem of NotesDocument.

You can get the value of an item through several techniques. The first two techniques do not require that you first access the item object.

  • After accessing the NotesDocument object containing the item, you can specify the item name as though it were a property of the document. For example, if doc is the name of a document object and Subject is an item in the document, doc.Subject is the value of the item.
  • You can use the GetItemValue method of NotesDocument.
  • You can access the item and examine its Values property.

To get the value of a date-time item as a NotesDateTime object rather than a Variant of type Date, use GetItemValueDateTimeArray or GetValueDateTimeArray.

To get the text values of the items named Received in a document, use GetReceivedItemText.

If multiple items in a document have the same name, programmatic access is limited to the first item. The remaining items yield invalid data. A work-around is to get the first item, process it, remove it, again get the first item (which was the second item), and so on until you process and remove all the items of a particular name. If you do not save the document, the items are not actually removed. However, the recommendation is that you avoid creating multiple items with the same name.