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 !
arvindmalikAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bozzie4IT ArchitectCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.