Dim doc As NotesDocument
'...set value of doc...
If doc.HasItem( "Subject" ) Then
Messagebox _
( "There is a Subject item on this document." )
Else
Messagebox _
( "There is no Subject item on this document." )
End If
返答のフォーム上に親文書の [Subject] フィールドから値を引き継ぐ [OriginalSubject] フィールドを作成します。これは正しく動作しますが、[Original Subject] の値がない返答文書がまだいくつか残っています。この問題を解決するために、次のスクリプトを作成します。スクリプトは HasItem を使用して、現在の文書のメインビューで OriginalSubject アイテムを調べます。HasItem が False を返すとき、スクリプトは AppendItemValue を使用して OriginalSubject アイテムを作成します。
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim mainDoc As NotesDocument
Dim responseDoc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "Main View" )
' get the first document in the view, which is a Main Topic
Set mainDoc = view.GetFirstDocument
' visit every Main Topic in the view
While Not ( mainDoc Is Nothing )
' get the first response to the Main Topic
Set responseDoc = view.GetChild( mainDoc )
' visit every response to the Main Topic
While Not ( responseDoc Is Nothing )
If Not (responseDoc.HasItem("OriginalSubject")) Then
' copy the Main Topic's Subject item into the
' Response's OriginalSubject item
Call responseDoc.AppendItemValue _
( "OriginalSubject", _
mainDoc.GetItemValue( "Subject" ) )
Call responseDoc.Save( True, False )
End If
' get the next response to the Main Topic
Set responseDoc = view.GetNextSibling( responseDoc )
Wend
' get the next Main Topic
Set mainDoc = view.GetNextSibling( mainDoc )
Wend