I’m trying to run a web agent without success (the agent was working fine before…).
My document is open on the web and from an action button I can my agent:
@Command([ToolsRunMacro]; “(Web GoToWIP)”)
My script does not recognized my current document.
I minimized my script to this :
Dim session As NotesSession
Set session = New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
Print "<H2> Form : " + doc.Form(0) + "</H2>"
My field value is always empty, but the doc is NOT nothing (not even a value for the form field.) I tried the doc.UniversalID, it returned a value, I did a search with this value in the database, any document with this id…
Have you taken a look at the Request_Content of the DocumentContext? I have a sneaking suspicion that you’ll find that the agent thinks it’s been invoked with a GET rather than a POST (by a server-side redirect). If it IS a POST, then the Request_Content will have your field values in it.
It means my guess was probably correct, that the agent thinks it was served to reply to a GET request. That means that you’ve got nothing but the request header and the URL to work with – the form the button was on, and the fields that were on that form, are not available to you at all. If you need the values that were on the form, then you’ll need to make the agent a WebQuerySave agent, or POST the form directly to the agent. This JavaScript should do the submit:
function switchAndSubmit() {
document.forms[0].action = ‘’;
document.forms[0].submit();
}
Make your button run the switchAndSubmit() function instead of the Formula Language, and you’re all set.
You will have to parse the values out of the Request_Content. Since you’re on ND6, you can use the Split method to separate the values out into an array like:
Then, for each of the array members, you’ll find the fieldname with StrLeft (using “=”) and the value using StrRight (again, using “=”). If you want, you can create fields on your DocumentContext:
That, unfortunately, creates the fields with text values. You can add handling to the agent to convert the strings to the correct data type to fill the fields, and you can also separate multiple values if you need to (as long as you know ahead of time what the separator should be). You’ll also want to make sure that a field is not created for _Click if you need to save the document.