1
votes

Hi I am new in using lotus notes 9 , i created a form with some fields and a save button that is calling a java agent ! my problek is when i excute the form and click the button i get an error saying that the document is not saved. this is the agent code. thank you

import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.Session;

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 = agentContext.getDocumentContext();

        doc = db.createDocument();
        doc.save();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

2

2 Answers

1
votes

Document doc = agentContext.getDocumentContext(); will retrieve the in-memory document. Your document isn´t saved yet; so you don´t have a doc in memory.

save your doc first an then run an agent with getDocumentContext.

1
votes

Also check the "Target" in the agent properties (Basics tab). It's probably set to "All Selected Documents" If it's not set to "None" you can get that same error message.