Passing fields values to java agent

I have a java agent that will post to an external server. Can I need to send some field values from a document.

excerpt:

Session oSession = getSession();

		AgentContext oAgentContext = oSession.getAgentContext();

		Database oDatabase = oAgentContext.getCurrentDatabase();

need to get some fields:

Get Lotus variables

lotusUniqueID =  ???

lotusFrom =  ???

can I just use the back-end classes here?

notesdocument = oDatabase.CuurentDocument

lotusUniqueID = notesdocument.field1(0)

TIA

Subject: passing fields values to java agent

Not sure I understand the scenario completely, but to get a handle to a contextual document in a Java agent, you have a couple of standard options:Session oSession = getSession();

AgentContext oAgentContext = oSession.getAgentContext();

Document doc = oAgentContext.getDocumentContext();

Database oDatabase = oAgentContext.getCurrentDatabase();

or

Session oSession = getSession();

AgentContext oAgentContext = oSession.getAgentContext();

Agent nAgent = oAgentContext.getCurrentAgent();

Database oDatabase = oAgentContext.getCurrentDatabase();

String strNoteID = nAgent.getParameterDocID();

Document doc = oDatabase.getDocumentByID(strNoteID);

hth,

dgg

Subject: RE: passing fields values to java agent

Dallas - thank you. I’m reasonably sure that your suggestion is what I need to get into that document.

Once into to the doc - I can use get getItemValue method to access the data. I’m testing right away.

Many thanks! JD

Subject: passing fields values to java agent

Jon,

To my knowledge, extended syntax doesn’t work in Java. so you need to use the method GetItemValue instead once you get a handle on the Document object.

hth.

brandt

Subject: RE: passing fields values to java agent

Thanks Brandt.

My problem is I’ve searched the java/Corba classes extensively. Since java has no “front-end” methods, I don’t know how to get the handle to the “Current Document” like you do in LS.

I can get a document - for instance - by searching by UNID:

oAgentContext = oSession.getAgentContext();

		Database oDatabase = oAgentContext.getCurrentDatabase();

		DocumentCollection dc = oDatabase.getAllDocuments();

  		Document oDatabase.getDocumentByUNID(doc.getParentDocumentUNID());

BUT - how do I pass the UNID? use an environment variable?

Can you give me any suggestion?

Thanks in advance.

Subject: RE: passing fields values to java agent

Hi Jon.

Perhaps it will help us if you try to explain what you are trying to accomplish, and how. How is this code being called?

The Notes Java API cannot, and wont interact with the UI Workspace. You can run a java agent, but even that agent will not interact directly with the Notes GUI interface.

Anyhow, you can pass 1 paramater to a java agent, by calling the agent like:

agent.run(noteId)

And then, in the java agent, you retrieve that Note ID by using a session object:

session.getParameterDocID();

I’m not sure what else you’re doing here- you mentioned something about a separate server. Using this method won’t even help you if you’re using a different database on the same server, because it’s a Note ID, not UID.

  • Steve

Subject: RE: passing fields values to java agent

Steve, thanks for the detailed response. And, yes you are correct, I’m probably going to have to use a trigger agent - as you suggest

<bold attempt at sounding like I know what I’m doing>

Ultimately what I’m trying is as follows:

On some event - ie, trigger - I’d like to connect to a remote server and pass some notes field data, using the java agent. The java agent is already set up to connect and post:

Context c= new Context();

c.connect(“server”, “Name”, “pw”);

IData outIdata = c.invoke(“LotusTest”, “getremote”, inputthedata);

but I needed the initial code to get the domino data. Using Dallas’ suggestions, I believe I’m now getting that.

Now that I have the domino data, I had tried using then QueryClose event (as the trigger) - because I assumed that at that point the document was already saved - but the data seems to be still in the scope of the UI.

So now your suggestion is very timely because the next step is to get to the document via another (Lotus) agent.

I hope this makes some sense.

Thanks again. JD