JAVA/CORBA CLASSES


Examples: copyItemToDocument method
This agent copies two items from an existing document to a new document, renaming one of them.

import lotus.domino.*;
import java.util.Vector;
import lotus.domino.*;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
 public void NotesMain() {
   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();
     // (Your code goes here)
     Database db = agentContext.getCurrentDatabase();
     DocumentCollection dc = db.getAllDocuments();
     Document doc = dc.getFirstDocument();
     if (doc != null) {
       Document newdoc = db.createDocument();
       Item item = doc.getFirstItem("Subject");
       item.copyItemToDocument(newdoc);
       item = doc.getFirstItem("Body");
       item.copyItemToDocument(newdoc, "BodyPrototype");
       newdoc.save(true, true);
       }
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also