• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 877
  • Last Modified:

CHALLENGE : passing value from lotus script agent to web form

i have aweb form,on the click of a button on it , a lotus script agent call , this agent also have java script code. alert message in JS is working fine but when i assign some string variable to field on form through java script , it show the message "document.forms[0] has no properties".

code:

Print | <SCRIPT LANGUAGE=""JavaScript"">{document.forms[0].textfield.value="fill this"; |
      Print | alert("this is alert"); |
      Print | history.back();}</SCRIPT>|

IT WOULD BE GREAT HELP !
0
arvindmalik
Asked:
arvindmalik
2 Solutions
 
Bozzie4Commented:
well, yeah, that's normal, because you create a new html page in your agent.

Print | <SCRIPT LANGUAGE=""JavaScript"">{document.forms[0].textfield.value="fill this"; |
     Print | alert("this is alert"); |
     Print | history.back();}</SCRIPT>|

is really

Print | <html><body><SCRIPT LANGUAGE=""JavaScript"">{document.forms[0].textfield.value="fill this"; |
     Print | alert("this is alert"); |
     Print | history.back();}</SCRIPT></body></html>|

If you want to get data back to the original document/form/page, you'll need to do this slightly different.

What you could do:
create a button in javascript, that doesn't directly calls the agent, but opens a new document (use openwindow javascript method).  Now open a form, where you have your agent as QueryOpen agent.  You can now write back to the original document using the opener (or parent, I'm not sure) property of the currently opened window.
Writing back would look like opener.document.forms[0].textfield.value

Of course, this means you must completely rewrite your agent.  There are of course , other ways to get data back from your agent in the document you were working...

cheers,

Tom
0
 
qwaleteeCommented:
Hi arvindmalik,

If you are trying to retrieve data from the existing form when the agent is called, you cant do it the way you are describing Domino web applications are similar to client/server programs (or like n-tier systems) You are mixing up the "client" portion and the "server" portion The client portion is the browser where the form DISPLAYS and where JavaScript executes. The server portion is what processes the submitted data and runs the agents, retrieves additional data and creates HTML for the client to use.  What ties it together is the HTML file that DOmno dynamically generates and sends to the client so it knows what to display and knows what JavaScript to use, plus the browser's ability to take URLs and request them or take forms and send their data back.

The print statements in an agent create HTML for the browser to interpret, but the browser sees the HTML as a new page, which it usually has no way of relating to the old data in the prior page (which had the form).  The agent does not have the form either, it only knows thatit was called somehow, which happens to be in the context of a request from teh web browser.  You either had a [ToolsRunMacro] command to run the agent, or you created a URL directly to it, or you implicitly ran the agent via WebQueryOpen or WebQuerySave.  Note that in a WebQueryOpen, the print statements have no effect, as the form generates the HTML, not the agent.

A) So, if you were trying to have the agent add additinal JavaScript to a form as the form opens, you can't do it with print statements.  That would either be done "natively" on the form (pass through HTML or the JavaScript coding areas of the form), or you could have an agent ggenerate JavaScript that gets placed in a read-only field marked as pass through HTML.

B) If you inteded the agent to change some data on the form when it is subitted, then you shoudl be manipulating the document before it is saved to the database.

C) If you are trying to have the agent manipulate the form that teh user is seeing -- user loads form, makes changes, does something to cause the agent to run, and see the form again with changed data,butit has not been saved yet -- then you are probably using the wrong approach.  You want that to happen via the methods in (A) above.  This is possible to do via the server, but much more complex.


Best regards,
qwaletee
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now