Search code examples
javalotus-noteslotus-dominolotuslotusscript

DocumentContext not returning value


I am using following code in a Java Agent in Lotus Notes:

Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Document doc = agentContext.getDocumentContext(); 

But it is returning docvariable as Null value. I am initialting agent in LotusScript code in postsave of the form. When I am using it in postsave by ToolsRun MAcro it is running fine. But initiating it by Run method of Lotus Script is not working at all.

can anyone help me to know what could be the reason?


Solution

  • When you run an agent using the Run method, you can pass a NoteId and access it in the agent with the ParameterDocId property.

    I don't have a good explanation for the reason it is this way, however, the DocumentContext property does behave differently depending on the context in which the agent is running.