Domino Code Fragment

Code Name*
Adding an Item to All Documents Using AppendItemValue of NotesDocument
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.13.58.137.218
Description*
Adding an Item to All Documents Using AppendItemValue of NotesDocument
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
You can Use AppendItemValue method of NotesDocument to create a new Item. If the Item
already exist Notes AppendItemValue creates another Item of teh same name. if this is not
your intention use ReplaceItemValue.


Sub Initialize
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim dc As NotesDocumentCollection
    Dim item As NotesItem
    Set db = session.CurrentDatabase
    Set dc = db.AllDocuments
    For i = 1 To dc.Count
         Set doc = dc.GetNthDocument(i)
         REM CONDITIONAL ADDED SO ONLY DOCS WITH CORRECT FORM ARE USED
         If doc.Form(0) = "Listing 06-11: Adding item to current document" Then
              Set item = doc.GetFirstItem("Purchases")
              totalP = 0
              Forall value In item.Values
                   totalP = totalP + value
              End Forall
              Call doc.AppendItemValue("TotalPurchases", _
              totalP)
              Call doc.Save(True, False)
         End If
    Next
End Sub