次のエージェントは、現在のデータベース内に新規文書を作成し、Form、Subject、Categories、Body の各アイテムに値を設定し、文書を保存します。
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();
Document doc = db.createDocument();
doc.appendItemValue("Form", "Main Topic");
doc.appendItemValue("Subject", "Test Document");
doc.appendItemValue("Categories", "Test Documents");
RichTextItem rti = doc.createRichTextItem("Body");
rti.appendText("This is the first sentence of text.");
rti.appendText(" This is the second sentence of text.");
if (doc.save())
System.out.println("Document has been saved");
else
System.out.println("Unable to save document");
} catch(Exception e) {
e.printStackTrace();
}
}
}