Examples: GetItemValue method

In the following examples, doc is a NotesDocument whose value has been set as follows:

Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments 'This property only works in an agent that runs against a set of documents.

Set doc = dc.GetFirstDocument
  1. This script prints the contents of the Subject item in a document in a dialog box. In this case, GetItemValue returns an array of one element, so the code uses subj( 0 ) to access the first element.
    Dim subj As Variant
    subj = doc.GetItemValue( "Subject" )
    Messagebox( subj( 0 ) )
  2. This script achieves the same result using the extended class syntax.
    Dim subj As Variant
    subj = doc.Subject
    Messagebox( subj( 0 ) )
  3. This script sums every value in the quarterlyRevenue item on doc and places the result into the totalRevenue item. The quarterlyRevenue item is a number list, and the totalRevenue item is a number. For example, if quarterlyRevenue contains 50; 60; 70; 80, then totalRevenue gets assigned a value of 260.
    Dim total As Integer
    Dim money As Variant
    total = 0
    money = doc.GetItemValue( "quarterlyRevenue" )
    Forall m In money
      total = total + m
    End Forall
    Call doc.ReplaceItemValue( "totalRevenue", total )
    Call doc.Save( False, True )
  4. This script achieves the same result using the extended class syntax.
    Dim total As Integer
    Dim money As Variant
    total = 0
    money = doc.quarterlyRevenue
    Forall m In money
      total = total + m
    End Forall
    doc.totalRevenue = total
    Call doc.Save( False, True )
  5. This script gets the contents of the rich text item Body, which is returned as a single string, and places it into the Body field of a new mail memo.
    Sub Initialize
      Dim memo As NotesDocument
      Set memo = New NotesDocument( db )
      Dim bodytext As Variant
      bodytext = doc.GetItemValue( "Body" )
      Call memo.ReplaceItemValue( "Body", bodytext )
      Call memo.ReplaceItemValue( "Subject", _
      "Here's some plain text" )
      Call memo.ReplaceItemValue( "Form", "Memo" )
      Call memo.Send( False, _
      "dbattersly @ purple.peoplepleaser.org @ internet" )
    End Sub
  6. This script achieves the same result using the extended class syntax.
    Sub Initialize
      Dim memo As NotesDocument
      Set memo = New NotesDocument( db )
      memo.Body = doc.Body
      memo.Subject = "Here's some plain text" 
      memo.Form = "Memo" 
      Call memo.Send( False, _
      "dbattersly @ purple.peoplepleaser.org @ internet" )
    End Sub