Search code examples
lotus-domino

lotusscript agent calling another lotusscript agent not working


1.) On a web form, I have a Notes button (not an HTML input or button tag).....it calls a Lotusscript agent using @Command([RunAgent];"agentname") command ....that works fine

2.) Last line of this calls another Lotusscript agent using "runonserver"

3.) This second agent tries to use "DocumentContext" to identify the current document, but it does not seem to be able to do this, an error I logged indicates this to be the case.

So the question I have is...how could I have a first agent run, and successfully use "DocumentContext" and then call a second agent, and then have THAT agent identify the SAME document as the first one used? This second agent has its own:

  • Dim s as new notessession
  • Dim db as notesdatabase
  • Dim thisdoc as notesdocument
  • set db = s.currentdatabase

...and then it attempts to set thisdoc with : set thisdoc = s.DocumentContext

The second agent is used elsewhere as the primary agent (not getting called in a daisy-chain situation) and it all works fine.

Maybe there is a simple solution that I am just not thinking of at the moment. I know I can put two @Command([RunAgent]... commands behind the button, but that has its own challenges, so I am wondering if someone as some slick/clever idea of what I can do.


Solution

  • DocumentContext is a memory construct passed to the agent, so there is no such thing in the database.documentcontext. What you'll have to do is save the DocumentContext as a document and then pass the NoteID (not the UNID) to the second agent. See if this works for you.

    https://www.ibm.com/developerworks/lotus/library/ls-Run_and_RunOnServer/index.html