Still unsolved

Hi here is my problem

I have a form and a action on it, the form should run on the web.

the action has the following code:

@Command([FileSave])

So I guess she should triger the agent that is refernced per WebQuerySave.

Here is the code in WebQuerySave:

@Command([ToolsRunMacro]; “Cnm”)

“Cnm” is the name of the agent as it stands in his properties although I have changed it for a while with “(Cnm)” not in the properties but in the reference in the WQS. And it worked that confused me.

Nothing, realy nothing happens when i click the action the browser remains as it is.

When i use a button on the form with this javascript code:

document.forms[0].submit();

I get a new page with the message Form processed.

Please help me

Here is the code that is in the agent:

Sub Initialize

Dim s As New notessession

Dim db As notesdatabase

Dim vw As notesview

Dim curdoc As notesdocument

Dim vwdoc As notesdocument

Dim brojugovora As String

Dim username As String

Dim password As String



Set db = s.GetDatabase("HERMES/pincom","pdm.nsf")

If db Is Nothing Then

	Print "<H1>Nemogu otvoriti bazu!</H1>"

	Exit Sub

End If



Print "<H1> Show something </H1>"

Set vw = db.getview("WICRnlg") 

If vw Is Nothing Then

	Print "<H1>"Nemogu pristupiti radnim nalozima" </H1>"

	Exit Sub

End If

Print "<H1>Nemogu otvoriti bazu!</H1>"



Set curdoc = s.DocumentContext

Print "<H2>" + doc.Subject(0) + "</H2>"

If curdoc.BrjRnlg(0) = "" Then Exit Sub 



Set vwdoc = vw.getdocumentbykey(curdoc.BrjRnlg(0))

If vwdoc Is Nothing Then

	Print "<H1>Nemogu pronaci radni nalog s tim brojem</H1>"

	Exit Sub

End If

Print "<p>" + vwdoc.doc_broj(0) + "</p>"

End Sub

Subject: Still unsolved

Hi Brane,

Print “

” + doc.Subject(0) + “

”

should be

Print “

” + curdoc.Subject(0) + “

”

When testing a webquerysave agent, I usually use an errorroutine that writes the linenumber to the browser if something goes wrong, so I know where to look and you don’t get the Form processed warning:

Sub Initialize

On error goto errorRoutine

…

…

Print “

” + vwdoc.doc_broj(0) + “

”

exit sub

errorRoutine:

Print "Error on line " +cstr(Erl())

Exit sub

End sub

When the agent works fine I dim/remove the errorhandling, since I don’t want the user to be bothered by lines that means nothing to them.

Regards,

René

Subject: RE: Still unsolved

Hi Rene

I followed your instructions and nothing has changed.

I am not sure does the agent run at all.

It seems to me that the form just reloads.

Thank you

Subject: RE: Still unsolved

Hi,

try removing all code from the agent and test:

Print “

” + “Some string” + “

”

Form Processed appears only when there is some error occurs in the agent. Rene point is very valid.

Subject: Still unsolved

  1. Change @Command([FileSave]) to:@Command([FileSave]);

@Command([FileCloseWindow])

  1. You can normally not open other servers from your agents unless the server is set as trusted in server document. You are probably getting error in line Set db = s.GetDatabase(“HERMES/pincom”,“pdm.nsf”)

Try to change it to:

Set db = s.GetDatabase(“”,“pdm.nsf”)

Subject: RE: Still unsolved

Yes you were right Andei, but is it then a security issue? And I am not sure where to find server doc

Thanks

Branimir

Subject: RE: Still unsolved

After trusting server one to server two and vice versa still the same problem happens error on line 18

Subject: RE: Still unsolved

It looks like you’ve got a handle to the database, but that it is not open

Check if the database is open:

Set db = s.GetDatabase(“HERMES/pincom”,“pdm.nsf”)

If db Is Nothing Then

Print “

Nemogu otvoriti bazu!

”

Exit Sub

End If

If db.isOpen Then

	Print "Database is open - 1"

Else 

	Call db.open("","") 

	If db.isOpen Then 

		Print "Database is open - 2"

	Else

		Print "No access"

exit sub

	End If

End If

If it is still not open the agent has no access to the database.

Subject: RE: Still unsolved

Hi Rene

You were right it prints No Access in browser.

How can I grant the agent access to the database.

Wenn I do it in client it says Database is open - 1

It confuses me why can the agent access the databse over the client but not over the web?

Thank you

Subject: RE: Still unsolved

When you run the agent manually, it runs with your id. Since you obviously have got rights on the other database, it runs ok.

A webquerysave agent looks at the security settings of the agent.

Open the agent properties, second tab.

Run as web user should not be checked.

Set runtime security should be 2.

Also, check if the server has rights on the database on the other server. If not, the agent cannot open the database since it runs with the server-id.

Subject: RE: Still unsolved

Hi Rene I did what you told me,

And the server has rights on the database,

when i run the agent I created with the piece of code you provided ma it sas No access but when i run the agent with changes Bjorn made http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/51b3a8a060b74cb68525725f00675e5b?OpenDocument

the designated frameset from the database opens!

So I guess I cann access the database but cant run the agent on it or what??

Thanks

Subject: RE: Still unsolved

Hi Brane,

I don’t exactly know what you mean by “the designated frameset from the database opens”.

It looks like your agent still doesn’t work?

Another option (I don’t know if it is possible for you to do) is to create a replica of pdm.nsf on the same server as where the agent runs. In that case you shouldn’t worry about trusted servers, etc.

Subject: RE: Still unsolved

Hi Rene is it ok for you if we contact over the msn messenger because it is really hard to explain the details over the forum!my messenger adress

branemxm@hotmail.de

Thanks

Subject: Still unsolved

When you are developing Web Query agents, it helps a lot to have access to the server console, or at least the log.nsf. Always when there is a security configuration problem, or an error, it will display there.

You can force messages to both the console, and the log by using msgbox “something” inside your code. If you are unsure if your agent is running at all, remove (or comment out) all code, and just leave a single msgbox, if it displays, you know your code is running…

I took the liberty to rewrite your code a bit, it should work now. (The comment about accessing servers that are not local still applies, and you need to set up a trust if you need this. Easier is to try to get a local replica of the lookupdatabase to your server, and it should be quicker too…)

Sub Initialize

Dim s As New notessession

Dim db As New notesdatabase("", "") '// declare it empty, so we can change it later

Dim vw As notesview

Dim curdoc As notesdocument

Dim vwdoc As notesdocument



Msgbox "if you see this in the server log/console, I am running!"



On Error Goto errorhandler



'// i use this method to get a database, since it ALWAYS returns a db, open or not

Set db = New NotesDatabase("HERMES/pincom","pdm.nsf")

If db.IsOpen Then

	Print "<H1> Show something </H1>"

	Set vw = db.getview("WICRnlg") 

	If Not vw Is Nothing Then

		Print "<H1>Nemogu otvoriti bazu!</H1>"



		Set curdoc = s.DocumentContext

		Print "<H2>" + curdoc.Subject(0) + "</H2>"



		'// if BrjRnlg is blank, you should find no document, so no real need to test for it

		Set vwdoc = vw.getdocumentbykey(curdoc.GetItemValue("BrjRnlg")(0), True) '// always use true, unless you know you wont need it

		If(Not vwdoc Is Nothing)Then

			Print "<p>" + vwdoc.GetItemValue("doc_broj")(0) + "</p>"

		Else

			Error 1003, "Nemogu pronaci radni nalog s tim brojem"

		End If

	Else

		'// view is nothing throw an error and exit

		Error 1002, "Nemogu pristupiti radnim nalozima"

	End If

Else

	'// throw an error and exit	

	Error 1001,  "Nemogu otvoriti bazu!"

End If

die:

Exit Sub

errorhandler:

'// just print the error and exit cleanly

Print |<h1>Error "| & Error & |" happened on line: | & Erl & |</h1>|

Resume die

End Sub

Subject: RE: Still unsolved

Hi Bjorn,

thank you for your answer. I Have created a new agent from your code and it opens the whatever is set up by the launch option of the database (“Launch as last viewed by user”, “Launch designated frameset” etc.).

I also have included a piese of code from Rene that tests if the database is open and it returns No Access.

I will try tu set the server as trusted and i hope it will work