Manage Learn to apply best practices and optimize your operations.

Passing Parameter from LotusScript Agent to Java Agent

Passing Parameter from LotusScript Agent to Java Agent and writing the data in Oracle using JDBC Oracle Thin Driver

This tip is all about how to pass a parameter Between LotusScript Agent and Java Agent from the Web and saving the values from the document to the Oracle table using JDBC Oracle Thin Driver.

How it works :
I got 2 agents, One is LotusScript Agent called "Lookup" which will execute when the document is submited via browser (WebQuerySave).

Other Agent is called "JavaAgent" which is triggered by the LotusScript "Lookup" agent. This Agent will take the values from the document and write it to the Oracle Table using JDBC Oracle Driver.

When the Document is submitted via browser, the "Lookup" Agent will execute first and it will send mails to the users listed in that document. After that it will trigger the "JavaAgent" and pass the NoteID of the current document to it.

JavaAgent will use the NoteId to process the current Document. This Agent will take the values from the document and write it to the Oracle Table using JDBC Oracle Driver.

LotusScript "Lookup" Agent Code :

Dim sess As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim memo As NotesDocument
Dim agent1 As NotesAgent
Set sess = New NotesSession
Set db = sess.CurrentDatabase
Set doc = sess.DocumentContext
Set memo = db.CreateDocument

If (doc.Status(0)="0") And (doc.SelectedButton(0)="Submit") And (doc.Flag(0)="0") Then			
Call doc.ReplaceItemValue("Status","1")
Call doc.ReplaceItemValue("Flag","1") 
Call doc.ReplaceItemValue("Dspstatus","Completed") 
Set item = New NotesItem(memo,"SendTo","")
Call item.AppendToTextList(doc.SendTo)
Call item.AppendToTextList(doc.All)
Call memo.AppendItemValue("Subject","Legal Entity Gateway - New Legal Entity Setup")
Call memo.AppendItemValue("Body","This Mail is all about how to pass paramenter between LotusScript Agent and Java Agent")
Call memo.Send(False)
'----- Passing the NoteID and Executing the "JavaAgent" --------------
paramid = doc.Noteid
Set agent1 = DB.GetAgent( "JavaAgent")
If Not(agent1 Is Nothing) Then
Call agent1.RunOnServer(paramid)
End If
Print |[/| + doc.dbPath(0) + |/All/| + |?OpenView]|

JavaAgent Code :

import lotus.domino.*;
import java.sql.*;

public class JavaAgent extends AgentBase {
	public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
String paramid = agent.getParameterDocID();
Document doc = db.getDocumentByID(agent.getParameterDocID());
System.out.println("Start of Program.........!"+NoteID="+paramid); //Display the NoteID.

//Oracle Thin Driver
String url = "jdbc:oracle:thin:@";
Connection con=null;  
con = DriverManager.getConnection(url, "DSN", "password");
catch (Exception e)
System.out.println("Rajesh ex="+e);
String sSQL = "insert into Table Name(ID,NAME,COUNTRY)values(?,?,?)";
PreparedStatement stmt = con.prepareStatement(sSQL);  
// Getting the Values from the document and Inserting into Oracle table.---

System.out.println("End of Program.........!");
catch(Exception e)

Great Domino does all !!

Dig Deeper on Lotus Notes Domino Administration Tools



  • iSeries tutorials'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 ...