Examples: Remove method (NotesAgent - LotusScript)
- This script removes the CalculateTotals agent from the current database.
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Forall a In db.Agents
If ( a.Name = "CalculateTotals" ) Then
Call a.Remove
End If
End Forall
- This script deletes the agent that's currently running. When the agent finishes running, it will no longer exist in the database.
' Self-destructing agent created 08/18/95 by N. Allen
Dim session As New NotesSession
Dim agent As NotesAgent
Set agent = session.CurrentAgent
Call agent.Remove
- This script finds the disabled agents in the current database that are owned by the current user, and asks if the user wants to delete them. If so, it deletes the agents from the database.
The script uses an array of type NotesAgent, arbitrarily declared to be ten elements, to hold the agents that are disabled and owned by the current user.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agentArray( 1 To 10 ) As NotesAgent
Dim count As Integer
Dim r As String
Set db = session.CurrentDatabase
count = 0
' find agents owned by current user and disabled
Forall a In db.Agents
If ( a.Owner = session.UserName ) And _
Not ( a.IsEnabled ) Then
count = count + 1
Set agentArray( count ) = a
End If
End Forall
r = Inputbox$( "You have " & count & _
" disabled agents. Delete them?" )
If ( r = "yes" ) Or ( r = "y" ) Then
' go through each agent that's owned by current
' user and disabled
Forall b In agentArray
Call b.Remove
End Forall
End If
End Sub