Is there any way to call a web agent from javascript (in a Form action), and access the field values of that document on the backend? Looking at the LDD help, it looks like using Domino URL only allows access to CGI variables. I am trying to write an agent to archive the document that is currently open, and copy its values to a new document, and then open the new one. Any suggestions on how to do this?
Subject: Need help understanding web agent, domino URL
Scott,
Some options:
- You can call an agent like this:
http:// … /dbname.nsf/AgentName?RunAgent&id=1234&name=fred+merkle&dept=Sales&
Doing this will allow the agent to do the following:
dim s as new notessession
dim doc as notesdocument
set doc = s.documentcontext
dim qs as string
qs = doc.Query_String_Decoded ( 0 )
And then you can pull out all those field values from the URL
- Or you can save the document, run a webQuerySave agent, and have the agent read the values from the document and then mark it for deletion.
regards,
raphael
Subject: RE: Need help understanding web agent, domino URL
Thank you. I think option 1 is the one I’d like to use. Is it possible to use ?OpenDocument to open the new doc before saving it? For instance I am trying to mimic the following code below (from Notes client) but for the web:
Dim ws as New NotesUIWorkspace
Dim session as New NotesSession
Dim db as NotesDatabase
Dim doc as NotesDocument
set db = session.CurrentDatabase
set doc = db.CreateDocument
doc.Form = “Form A”
’
’
’
fill-in some fields for doc
’
’
’
call ws.EditDocument(doc)
Thanks again for the help.
Subject: RE: Need help understanding web agent, domino URL
If you call your agent using @command([ToolsRunMacro]) behind an action or hotspot button, then NotesSession.documentContext gives you the handle to the actual document the user was working on.
Otherwise you need to include either a hidden field containing the document unique ID of the document
e.g. put in the following text and then make it passthru html if you are not using ‘generate html for all fields’ option, in which case, just make a hidden computed field and notes will do the rest.
You can get the document unique as part of the HTTP_REQUEST_CONENT via script or include in the URL that the user clicks on to call the agent and parse out.
Use the value you get to getDocumentbyUNID to get a handle on the document