Represents a discrete value or set of values in a document.
The client interface displays items in a document through fields on
a form. When a field on a form and an item in a document have the
same name, the field displays the item (for example, the Subject field
displays the Subject item). All items in a document are accessible
programmatically, regardless of what form is used to display the document
in the user interface.
Creation
To create a new NotesItem object:
- To create a new NotesItem object from scratch, use replaceItemValue in
Document. The method appendItemValue also
creates an item, but creates another item of the same name if the
specified item exists. Use replaceItemValue unless
your intent is to create another item with the same name (not recommended).
- To create a new NotesItem object from one that already exists,
use copyItemToDocument, copyItem in Document,
or replaceItemValue in
Document.
You must call save on
the document if you want the modified document to be saved to disk.
The document won't display the new item in the user interface unless
there is a field of the same name on the form used to display the
document.
Explicitly call setSummary and
specify true if you want the value to be displayed in a view or folder.
Access
To access an existing NotesItem object:
- To access an item when you know its name, use getFirstItem in
Document.
- To access all the items in a document, use getItems in Document.
Document has methods to access items without creating a NotesItem
object. You need to know the name of the item.
- To get an item's value, use getItemValue.
- To create a new item or set an item's value, use replaceItemValue.
- To check for the existence of a particular item in a document,
use hasItem.
- To delete an item from a document, use removeItem.
Rich-text items
RichTextItem inherits the
properties and methods of Item and has additional properties and methods
you can use to manipulate rich text.
Saving Changes
After you create or modify an
item, you must save the changes by calling the parent document's
save method. If you don't
call
save before the
program finishes, all of your changes to a
NotesItem object are lost.