Link to home
Start Free TrialLog in
Avatar of imjamesw
imjamesw

asked on

Trouble debugging web agent

Hi All

I need to debug a web agent

I have tried using Print statements, however it does not seem to working

Any ideas or hints

thanx a bunch

James
Avatar of p_partha
p_partha

Print statements are returned as the output to the browser when the document is submitted through javascript (document.forms[0].submit() and not through formula @command([filesave])

if you want to debug through the log, then use msgbox, This will print the values in the log file

Partha
Avatar of imjamesw

ASKER

I am using lotusscript called via WebQuerySave

@Command([ToolsRunMacro]; "agtWebCancellationSave")
Oh there are lot of things you ahve to tell me:

First Does your agent has run once @commands may be used as the option on which documents it should act on

when you say you are calling webquerysave , how are you doing it. Are you submitting the page using document.forms[0].submit() or @command([filesave])

partha
Probably there are errors in the agent also , check the log file or give the print statement as teh first line in your agent

Partha
run once @commands may be used =Yes

Using a coded submit button on the form

//before submitting this form, validate and add this session to the user's calendar.
frm=window.document.forms[0];
if (validate(frm.NWIDTX))
{
      frm.submit();
}
Just to verify do all this:


frm=window.document.forms[0];
if (validate(frm.NWIDTX))
{
alert('submitting')

     frm.submit();
}

and in your agent the first line is :

Print "coming inside the agent"

also check your log file
Ok

so I got a msgbox popup saying submitting
and coming inside the agent on a page in the browser
12/01/2004 02:30:02 PM  Agent '(WebCancellationSave) | agtWebCancellationSave' error: Object variable not set
Yeah there is a error do one thing:

first line in your agent:

On error goto par

last line in your agent
exit sub
Print "Error occurred on line number" & erl & " errror is " & error
exit sub
ASKER CERTIFIED SOLUTION
Avatar of p_partha
p_partha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Error occurred on line number87 errror is Object variable not set
log.nsf records the error msgs..that is ur best bet

~Hemanth
It's tough to explain to you what might be the problem , paste the 87th line alone.. i will try to explain

partha
I have found that problem

It was looking to a non existent html paage      
Error occurred on line number0 errror is
Good ! it;s always better to have on error and print statements :)

Partha
YOu need ot have a exit sub above your error Label statement

partha
Now I need to put print statments in the agent

strFirstName = docCancel.RFirstName(0)
strLastName = docCancel.RLastName(0)
strCourseName = docCancel.RCourseName(0)
strSessionDate = docCancel.SessionDate(0)
strSessionTime = docCancel.RSessionTime(0)            
just give
Print strFirstName
Print strLastName
Print strCourseName
Print strSessionDate
Print strSessionTime

Partha
Nothing


Where should this go in the agent

I put under the above statments
This is nor updating the log file either

weird
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sjef Bosman
I hardly ever use Print or MsgBox to do debugging. I created a logging class with functions that log to 1) the agent's log, 2) a mail, 3) a database based on AgentLog template, 4) any combination of the three. The debugging level is selectable in a profile document.

I use the NotesLog class to do the logging. You might want to check that class in the Help db. The easiest place to log to for an agent is in it's own log. You can inspect the agent's log when you open the db's agents view, right-click on the agent, you'll see Log... at the bottom.

Basically, I stuff the code with sensible logging statements, and, of course, the On Error Goto as described above by Partha.

I hope you can find the error. Investing in a set of logging-functions like mine really pays off in the long run.
yes, but for development purposes, it's easy to quickly add a msgbox statement, just to see how far the code runs without problems (for instance).

Just remember to remove them after development, because they do cause some degraded performance (no logging = faster)
Then a Noteslog class is better : only create it and only log on errors!

cheers,

Tom
Partha: Jackpot!