我有以下代码:
Forall agent In db.agents
'I need to remove "$MachineName" item from all agents
End Forall
如何删除" $ MachineName" NotesAgent中的项目?或者我如何将NotesAgent转换为NotesDocument以便我可以删除此项?
答案 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