Is there any way to run agent.RunOnServer in asynchronized way?

Running notes client on a PC in one country and server on another country would be a big problem. Some process running on client side is terribly slow, and sometimes it even dies.

So I have to re-write some LS codes and try to run those on server side.

Client side is still waiting for return status from server when it kick off agent.RunOnServer (Notes ID). Any other way to run the similar process in asychronized way?

Thanks!

Subject: Yes there is.

There are a couple ways to do this, and how you do it depends on whether you have the HTTP service available, how familiar you are with creating HTTP POST, and how much data you need to transfer to the external process. With either method you should have a place where the results of processing are stored (I presume you have that already.)

The first method tries to use only LotusScript and Notes objects. You must create a database to store the request from the user. A request is just a Notes document with the information regarding what the agent is supposed to do. Here are the steps…

  1. Create the request and execute the “kicker” agent using RunOnServer.

  2. The “kicker” will kick off the real agent using SendConsoleCommand of NotesSession.

  3. The real agent will execute and process waiting requests.

  4. The agent will deposit the results in the results db and either send an email to the user (with a doclink) or send a console command to broadcast to the user a message that the job is complete.

In this way you can have the process execute immediately and have the user notified immediately.

The second method improves upon the first in that you don’t need a kicker agent, don’t need a requests database, and can receive a “good-to-go” acknowledgement of the passed data. The second method uses the HTTP protocol to communicate with the agent. So here are the steps…

  1. Prepare POST data containing the information required for your request.

  2. Execute an HTTP POST to execute the agent.

  3. The agent can validate the data and use a Print statement to return a response.

  4. The agent processes the request as described above.

If you’re comfortable with creating and receiving HTTP POST requests in LotusScript, and the HTTP process is running on the server, then that’s probably the best way to go. Otherwise, the more kludgey LotusScript method should get the job done.

Good Luck!

Subject: Excellent suggestions…

  • I used the HTTP method a while back, only to find the production server used a custom web-login product that broke the POST/GET mechanism with a login screen that the code didn’t expect. I’m sure it’s possible to work around that, but the main point is there are caveats to this, where the “kicker” solution essentially works as long as you may access the server using the Notes Client.

Hope this helps…

Subject: Wow…how strange.

Did you get a login even if you set the “Allow Public Access users to view and run this agent.” option in Agent properties → Security tab? I would expect such an add-on to allow access public design elements without a login…or at the very least allow you to configure a “public website”…some db that anyone can open.

I was looking at it from more of an internal, behind-the-firewall type configuration, where HTTP isn’t normally used. Otherwise, if it’s a web environment you don’t have this problem, since you’re logged in already. I wouldn’t expect such an add-on in a Notes client environment, but yes…you never know what you’re going to run into.

When I put a database on the internet I nearly always set Anonymous to No Access, but with read & write (if needed) access to public documents. Then I can set the “Allow Public Access…” option on agents so they can be executed without getting a login. I find using public access easier for giving access where necessary while protecting the rest of the db. This works well for internal processes, like the type I described.

Subject: This particular product did per app logins…

  • The code I was attempting to invoke was in another database in the same directory. Notes would allow this, but the product saw it was another database and popped a new login. It weren’t pretty.

  • I confess I didn’t try Allow Public Access, but I’m fairly certain it would have made no difference, because Notes nor Domino were the issue. The third-party web-login add-on to Domino was the issue. We have since stopped using that particular product, afaik.

  • Not likely for Sean, but still something that bit me in the posterior, but hard, so I tossed it out there. (shrug)

  • Barring such oddity, I find HTTP much simpler to employ, and would favor that approach…

Subject: Create or Modify trigger (re: Is there any way to run agent.RunOnServer in asynchronized way?)

Instead of using the RunOnServer method from the client, set the agent as scheduled on the server and use the trigger “After documents are created or modified” and then on the client side, have your trigger function create a new document (token) in the server db, which the scheduled agent will then see and fire. In this token document you can pass any parameters you need to if you were using the paramdoc function of runOnServer. The agent can notify the user via email when it completes.

Subject: RunOnServer

agent.RunOnServer cannot be run asychronized as it stands now.

You can perhaps trigger the agent to run on the server using an event (document change, mail arrival) and then check the status of the process by depositing some information in a document which both client and server are aware of.