I’m new to Java and I am trying to update several documents from a button on a form.The button is in LScript and calls a Java agent.
I can write and update several other documents, but I cannot write into the current document, which I retrieve in the Java agent.
Here is the simplified code in the Java agent:
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
Document oldDoc = db.getDocumentByID(agent.getParameterDocID());
if (oldDoc == null)
{ System.out.println("Current Doc Not Found");
} else { System.out.println("Current doc found !");
}
oldDoc.replaceItemValue("Field", "Field Value");
if (oldDoc.save())
{
System.out.println(“Doc Saved”);
} else {
System.out.println(“Doc Not Saved”);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Java console displays: “Current doc found !” and “Doc Saved”. However, the current documents doesn’t get updated. The field I am trying to update is text type.
What do I do wrong ?
Thank you.