Search code examples
xpageslotusscript

LS Agent to process selected documents from xpage


I would like to offer users the ability to select multiple documents ( or a single doc) and click a button to call a LS agent to cycle thru those documents and do some processing. I know i can send down a doc id ( as in a query save agent), but how to send an array, or a string of multiple values that I parse in the LS agent?

TIA


Solution

  • In the XPage, you can use a temporary document to pass values as you like to your agent:

    var agent = database.getAgent("myagent");
    var doc = database.createDocument();
    doc.replaceItemValue("docIDs", <your array with IDs>);
    agent.runWithDocumentContext(doc)
    

    and in the agent

    dim session as new notesSession
    dim tmpdoc as notesDocument
    set tmpdoc = session.documentContext
    dim array as variant
    array = tmpdoc.docIDs
    

    Note that you don't need to save the temporary document at all.