Trying to set a field from an agent on the web

I am running an intranet application and I open a form call Sections, from that from I have an agent that run from the WebQueryOpen, the agent does some calculations, from there I need to set a field on the Form Sections . How can I accomplish this if any possible. I am using script in my agent.

thanks

Brig

Subject: Trying to set a field from an agent on the web.

I am running an intranet application and I open a form call Sections, from that from I have an agent that run from the WebQueryOpen, the agent does some calculations, from there I need to set a field on the Form Sections . How can I accomplish this if any possible. I am using script in my agent.

I need to reconsider this.

When the user tries to access a link on the web, the Section form that has the agent running from there if the value is false then I need to have a javascript code that will have a message to the user that they cannot access that section as they did not do the previous section also I want to send them back to the previous page history.go(-1)

I have tried to write javascript in the script agent but I am successful about it…

alert (“Please complete previous section” );

history.go(-1);

any ideas how to do it…

Brig

Subject: RE: Trying to set a field from an agent on the web.

A WQO agent is run on the server, not in the browser. To set a field on the document, get the DocumentContext from the Notessession, and access it as any other document.

dim ns as new notessession

dim doc as notesdocument

set doc = ns.documentcontext

call doc.replaceitemvalue(“fieldname”, “value”)

For JavaScript that is to be executed in the browser, you need to put that on the form, or in a .js file or some other way. You can’t put it in an agent. Agents doesn’t execute in the browser, they execute on the server.

/Peter

Subject: RE: Trying to set a field from an agent on the web.

one way to accomplish your goal here is to have a computed field somewhere on your form called, let’s say, JSToExecute.

Place the computed field at the top of the form like so:

<script type="text/javascript>place field here</script> <p>and set the whole line to be PassThru HTML.</p> <p>Now, in your webqueryopen agent, create the javascript you want to execute as a string and place it in the JSToExecute field, like so:</p> <p>dim session as new NotesSession</p> <p>dim doc as NotesDocument</p> <p>dim strJS as string</p> <p>set doc = session.DocumentContext</p> <p>strJS = “alert(‘Hello world’);”</p> <p>call doc.ReplaceItemValue(“JSToExecute”,strJS)</p> <p>I have to say, however, that redirecting the user as soon as they open a webpage (by using history.go(-1), for instance) is not the best way to do things, since it creates a longer wait time for them with multiple server trips. I would recommend finding a better way to accomplish your goal here. Like maybe not letting them leave the first screen until they have completed it?</p>