lotus-noteslotusscript

Passing of parameter from Database1-Agent to Database2-Agent using Lotusscript


I would like to ask if it is possible to pass parameters (for example: fieldA and fieldB value) from Database1 using an agent, and triggering Database2-agent to accept the parameter being passed?

Not sure if it's possible. Thank you!


Solution

  • There is a -partly undocumented- function to pass a complete in- memory document to an agent without saving it. Like that you can pass anything from one agent to another. But it only works if one agent calls the other:

    Dim ses as New NotesSession
    Dim db2 as NotesDatabase
    Dim agent2 as NotesAgent
    Dim docTemp as NotesDocument
    
    Set db2 = New NotesDatabase( "Server", "db2Path.nsf" )
    Set agent2 = db2.GetAgent( "NameOfAgent2" )
    
    Set docTemp = New NotesDocument( db2 )
    
    docTemp.Parameter1 = "Some string"
    docTemp.Parameter2 = "Another String"
    docTemp.AnyNameYouWant = 3
    
    Call agent2.runWithDocumentContext( docTemp )
    

    Then in the agent two you access the document like:

    Dim ses as New NotesSession
    Dim docTemp as NotesDocument
    
    Set docTemp = ses.DocumentContext
    
    param1 = docTemp.Parameter1
    param2 = docTemp.Parameter2
    numParam1 = docTemp.AnyNameYouWant