如何删除" $ MachineName"来自NotesAgent变量的项目?或者我如何将NotesAgent转换为NotesDocument以便我可以删除此项目?

时间:2014-05-18 12:18:48

标签: lotus-notes lotusscript

我有以下代码:

Forall agent In db.agents
  'I need to remove "$MachineName" item from all agents
End Forall

如何删除" $ MachineName" NotesAgent中的项目?或者我如何将NotesAgent转换为NotesDocument以便我可以删除此项?

1 个答案:

答案 0 :(得分:7)

您必须将代理作为设计元素。这可以通过NotesNoteCollection class:

实现
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim i As long
Dim nc As NotesNoteCollection
Dim noteid As string

Set db = session.CurrentDatabase
Set nc = db.CreateNoteCollection(False)
nc.SelectAgents = true
Call nc.BuildCollection
noteid = nc.Getfirstnoteid()
For i=1 To nc.Count
    Set doc = db.Getdocumentbyid(noteid)
    Call doc.Removeitem("$MachineName")
    Call doc.Save(true, true)
    noteid = nc.Getnextnoteid(noteid)
Next