Home > Domino Tips > Developer > Agent > Calling agent from Web without submitting a form
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

AGENT

Calling agent from Web without submitting a form


Jeff Kirkland
05.15.2002
Rating: -3.93- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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...

Code

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


Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Agent
Run or restart Notes/Domino agents via text messages
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts