0
votes

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.

2

2 Answers

2
votes

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

2
votes

Since you're trying to use the same agent from both a button and a RunOnServer call, and that can't work (as per @Duston's answer), your best bet is probably to move the bulk of that agent code into a sub or function in a script library, and then have two agents. One agent gets the document context as you do now, and passes it into the script library code. The other uses agent.paramaterID and getDocumentById and passes that into the script library code.