LOTUSSCRIPT /COM/OLE のクラス
例:アイテムとその値を取得する
1.
次の例では、NotesDocument の Items プロパティを使用してデータベースのビューに含まれる各文書のアイテムをすべて取得し、その名前とテキストの表現を表示します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
Forall item In doc.Items
Messagebox item.Name & " = " & item.Text
End Forall
Set doc = view.GetNextDocument(doc)
Wend
End Sub
2. 次の例では、NotesDocument の GetFirstItem メソッドを使用してデータベースのビューに含まれる各文書の Subject アイテムを取得し、その名前とテキストの値を表示します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
Set doc = view.GetFirstDocument
If doc.HasItem("Subject") Then
While Not(doc Is Nothing)
Set item = doc.GetFirstItem("Subject")
Messagebox item.Name & " = " & item.Text
Set doc = view.GetNextDocument(doc)
Wend
End If
End Sub
3. 次の例では、アイテム名を文書のプロパティとして使用して、データベースの各文書の Categories アイテムの値を取得します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
Set doc = view.GetFirstDocument
If doc.HasItem("Categories") Then
While Not(doc Is Nothing)
Forall category In doc.Categories
Messagebox category
End Forall
Set doc = view.GetNextDocument(doc)
Wend
End If
End Sub
4. 次の例では、NotesDocument の GetItemValue メソッドを使用して、データベースの各文書の Subject アイテムの値を取得します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
Set doc = view.GetFirstDocument
If doc.HasItem("Subject") Then
While Not(doc Is Nothing)
Forall subject In _
doc.GetItemValue("Subject")
Messagebox subject
End Forall
Set doc = view.GetNextDocument(doc)
Wend
End If
End Sub
5. 次の例では、ビューの各文書に、指定されたアイテムがあるかどうかを調べます。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
itemName = Inputbox("Name of item?")
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
If doc.HasItem(itemName) Then
Messagebox "Item present in document"
Else
Messagebox "Item not present in document"
End If
Set doc = view.GetNextDocument(doc)
Wend
End Sub
6. 次のエージェントは、同じ名前を持つ複数のアイテムにアクセスするための回避策を示します。これが回避策ですが、同じ名前を持つ複数のアイテムの作成は、お勧めできません。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
REM Get first FooBar item
Set item = doc.GetFirstItem("FooBar")
While Not(item Is Nothing)
Messagebox item.Text,, item.Name
REM Remove item from memory
Call item.Remove
REM Get next FooBar item
Set item = doc.GetFirstItem("FooBar")
Wend
End Sub
関連項目
LotusScript のクラスでアイテムとその値を取得する
用語集
フィードバック
ヘルプ
または
プロダクトユーザビリティ
ヘルプの使い方
すべてのヘルプ項目
用語集