Examples: copyItem method
This agent copies an item from an existing document to a newly created document.
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.search(
"Subject = \"Test appendItemValue\"");
if (dc.getCount() == 1) {
Document doc = dc.getFirstDocument();
Document docCopy = db.createDocument();
docCopy.replaceItemValue("Form", "Main Topic");
docCopy.replaceItemValue("Subject",
"Copy of test appendItemValue");
Item bodyItem = doc.getFirstItem("Body");
docCopy.copyItem(bodyItem, "");
if (docCopy.save())
System.out.println("Document saved");
else
System.out.println("Something went wrong"); }
} catch(NotesException e) {
System.out.println(e.id + " " + e.text);
e.printStackTrace();
}
}
}