Domino Code Fragment

Code Name*
Remove method
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.217.116.183
Description*
This script removes the agent in the current database named "Agent To Delete."
Type*
Java
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
import lotus.notes.*;
import java.util.Vector;


public class removeagent extends AgentBase
{
 public void NotesMain()
   {
   try
     {
       Session s = getSession();
       AgentContext ac = s.getAgentContext();
       Database db = ac.getCurrentDatabase();
       Vector agents = db.getAgents();
       int count = agents.size(), i;
       for (i = 0; i < count; i++)
       {
         Agent agent = (Agent) agents.elementAt(i);
           String name = agent.getName();
           if (name.compareTo("Agent To Delete") == 0)
            {
              agent.remove();
              System.out.println("agent found and deleted");
               break;
            }
        }
       if (i == count)
       System.out.println("agent not found");
     }
   catch (Exception e)
     {
       e.printStackTrace();
     }
   }
}