Search code examples
lotus-noteslotus-dominolotusscriptlotus-formula

Java Agent doesn't run in its own thread when called from Lotus Script


I have a Java Agent marked with "Run in background client thread". The agent runs fine when called by a formula statement like this:

@Command([RunAgent]; "MyAgent")

Which has the problem that I can't pass a document ID to submit my parameters.

Alternatively, I can call the agent with the parameters I want using Lotus Script:

Call shAgent.Run(doc.NoteID)    

Or like this:

Call MyAgent.RunWithDocumentContext(doc)

But the agent doesn't run in its own thread in this case. I am aware that other methods exist. But I would prefer to use agent for legacy reasons.

Is there a way to let the agent run in its own thread when called from Lotus Script or to pass parameters to it when called via Formulas without using environment variables?


Solution

  • You can pass parameters through profile document:

    @SetProfileField("MyProfileDocument"; "MyField"; MyValue);
    @Command([RunAgent]; "MyAgent")
    

    To get value in Java just use this:

    //Your code
    Document profileDoc = session.getCurrentDatabase().getProfileDocument("MyProfileDocument", null);
    Vector value = profileDoc.getItemValue("SomeField");
    //Your code