I have the following code:
Forall agent In db.agents
'I need to remove "$MachineName" item from all agents
End Forall
How can I remove "$MachineName" item from NotesAgent? Or how can I cast NotesAgent to NotesDocument so that I can remove this item?
You have to get the agents as design elements. This is possible with 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