Calling agent from Web without submitting a form

Calling agent from Web without submitting a form -- here's how I did it

One of my clients recently wanted to create a new document based on values entered in a Web form when a button was pressed, BUT didn't want the user to have to submit the form to trigger the agent. This had to happen completely in the background without a round trip to the server and even better; the agent was located in a different database on a completely different server hosted in another domain.

Here's how I did it...

On the user Web form, I created a small image that was an invisible GIF using an HTML image tag. This serves as a placeholder for the image I want to return from an agent later on.

 

 <img src="server/database/invisible.gif" name="image1">

On a button labeled "Create Document", I placed the following JavaScript code:

 

 document.forms[0].image1.src="/server/database/createdoc?openagent&id=" + form.data.value;

This JavaScript replaces the invisible GIF with a new image, in this case one returned by the LotusScript agent called "createdoc".

In the target Domino database, I wrote a LotusScript agent to create the required document and return an image to the browser. I used the query_string_decoded CGI variable to pass data from the Web form to the new document.

 

 'Create a document and return an image to the browser Dim session As New NotesSession Dim Webdoc As NotesDocument Set Webdoc = session.DocumentContext Dim db As NotesDatabase Set db = session.CurrentDatabase Dim doc As New NotesDocument(db) doc.query = Webdoc.query_string_decoded(0) if doc.Save(True,True) then 'Show a tick in the browser if all is well Print "[http://servername/database.nsf/cross.jpg?OpenImageResource]" else 'Show an x to indicate the document wasn't created Print "[http://servername/database.nsf/tick.jpg?OpenImageResource]" end if
This was first published in May 2002

Dig deeper on Domino Resources - Part 2

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close