We help IT Professionals succeed at work.

javascript run agent

leong9065
leong9065 asked
on
i want to make an interface to let user to select the document from the database. i plan to use the javascript popupwindow to show the document. but jaavscript run the agent directly.so i would like to know the way to solve the problem, thanks.

i have an idea to make an empty page and put the lotusscript agent in the postopen event in the empty oage and let the main form to call the page.
can it be done or should it be done int hat way?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Sure you can:
Like forms and views, agents have url's too! Simply launch that url in the popup window and the agent will execute.
If neccesary you can append additional info in the url, like:
"/mydb.nsf/myAgent?OpenAgent&Unid=....."

I assume you are triggering a lotusscript agent. That agent has its own NotesSession.DocumentContext, with already some CGI fields on it (Query_String_Decoded, HTTP_Referer etc.).... in case you need to retrieve those additional parameters, you'll know where to find them!

Now, everything printed by the agent is send to the calling window: if between square brackets, it ends up in the adress bar (opening that new url!), otherwise it is printed to the windows content (body). You can generate an entire HTML page, just as you would in an HTML editor.
Include <HTML>, <BODY> etc!!!

Author

Commented:
i try to call the agent in the popup window by using the agent URL.but it cannot load and end with the http error 500.
i use the lotus script agent to retrieve the data from the domino DB.then let the user to tick. then i need to send the selected document back to the parent form that call the popup window.how can it be done?
in the popup i use the embedded view to show the DB query document.
i mean how the value pass from the popup back the the parent form.
in the parent form, i created a "delegate" field use to store the value from the popup.

i hope you can understand my language.although i know is quite bad. but thanks alot.looking for your response as soon as possible.thankss
CERTIFIED EXPERT
Commented:
First the error:
In notes it would be the user that runs the agent. A browser client can't run agents: the server runs them instead.
The server probably has restrictions for the use of agents: check the fields "who can run restricted agents" and -if you access the server at file-level as well-: "...unrestricted agents".
You are probably not authorised to do so.

That means that -on the designer server- you need those privileges verify your archievements, and on test/production servers you will need somebody to "sign" the agent with an ID that is allowed to run agents there (sign = save).

The webuser then triggers the agent by URL, the agent runs on the server, using the signer id (note that notessession.EffectiveUsername returns the signer, not the web-user) and the result is send back to the browser.


For the agents code:
Simply start with following example:

Dim Session As New NotesSession
Dim Db As NotesDatabase
Dim i As integer
Set Db = Session.CurrentDatabase
Print "<HTML>"
Print "<HEAD>"
' you could add style-sheet code here
Print "</HEAD"
Print "<BODY>"
Print Db.DbTitle + "<Br>" ' example: data retrieved from a database
for i = 1 to 10
  print "<A HREF=""Javascript:alert(i)"">" + i + "</A>"
next
Print "</BODY>"
Print "</HTML>"


Give it a try and let me know if you need a hand! You already get the popup with and error (right? or does the error appear in the opeing window?), so you are on the right track!
Jean Marie GeeraertsApplication Engineer
Commented:
An error 500 (=Internal server error) always refers to an error in the agent.
Can be anything from a badly defined variable to an object that's not assigned.
I usually log some debugging info to an agents database to track the progress of web agents during development so I can check where it's gone wrong. Then once the agent is running perfectly, I remove all debugging code to speed up processing of the agent.
Are you using HTML View (like Check boxes) ?

You can manipulate the selection by using javascript.

Tthe window.opener refers to the unbderlying window which called the popup window, using that object you can set/get the field values from/to the parent.

If you need more on javascript function, let me know.

~Hemanth
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
leong9065,
No comment has been added lately (890 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: split points between CRAK http:#6496162 and jerrith http:#6498027 and HemanthaKumar http:#6500689
Please leave any comments here within 4 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

Zvonko
EE Cleanup Volunteer
Jean Marie GeeraertsApplication Engineer

Commented:
Another present from the past! Thanks again!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.