Hi
I have a very annoying problem. I have a lotusscript code that simply has to find a doc in a view. When I run the code manually( debugger) the document is always found. But when I schedule the script it returns an empty document handle. Here is the piece of code I am using.
Set ProdDb = GetProdDatabase()
Set ProdView = ProdDb.GetView(“Username”)
Set tmpProdDoc = ProdView.getdocumentbykey(xRepositoryKey$, True)
How is it possible that when scheduled tmpProdDoc is allways empty?
Regards
Subject: Scheduled lotusscript code never returns a document handle!
Check your function GetProdDatabase.
This function might return nothing when it’s run on the server.
Renaud
Subject: RE: Scheduled lotusscript code never returns a document handle!
Hi
The function does allways return a database because else I would get a “object variable not set” when the code GetView runs.
Subject: RE: Scheduled lotusscript code never returns a document handle!
Can it be then, that the db which is returned is not the “good” one when you run it on the server?
It might sound silly, but might happen that is returned when run on the server is not the same as when you run in on local.
maybe do an output of the db info on which you do the lookup just to be sure.
Renaud
Subject: RE: Scheduled lotusscript code never returns a document handle!
Hi
I have done that also.
I have used the debugger and whatched when the handle to the database and view was found. I looked at the properties of the database, they were the riht one. I looked at the properties of the view and watched the parentdatabase property and it was the right database .
Regards
Subject: RE: Scheduled lotusscript code never returns a document handle!
The debugger tells you what database you are opening when you run manually. The question is which database it opens when it runs on schedule? This can be different, for any of several reasons. What does the code that opens the database look like?
Subject: Scheduled lotusscript code never returns a document handle!
Are there any messages in the log when the agent runs?
Is the target database on the same server as the one from which the agent is being run?
Subject: RE: Scheduled lotusscript code never returns a document handle!
Hi
I have only 1 server in our testdomain There is nothing in the log because there is no error, only an empty handle to a document.
Regards
Subject: Scheduled lotusscript code never returns a document handle!
Does the target document have any Readers fields on it? If so, does the signer of the agent have access to the document?
Subject: RE: Scheduled lotusscript code never returns a document handle!
Hi
I am using the same id that has signed the agent when I run the code manually. So the id has full access to the target database and document.
There are no readers field on the form.
Regards
Subject: Scheduled lotusscript code never returns a document handle!
How many documents are in the view? Compare what notesView.EntryCount returns from manual run with what you get back when scheduled. I suspect scheduled agent is returning nothing.
Subject: Scheduled lotusscript code never returns a document handle!
OK, my wild idea…
You’re view is called UserName - is this a Private of First Use View? Does the view have @UserName as part of the selection formula?
I’ve never done anything like that as part of code and I’m wondering just because an agent is “signed” by an ID doesn’t meant it will work properly with a view using a @UserName when scheduled. (This may NOT be the problem - I’m just throwing out ideas).
I would try and find the document you’re looking for using another method like Search just to see if you get a different result.
Subject: RE: Scheduled lotusscript code never returns a document handle!
HI
The view is not private. The key that is being used in the view is the shortname(e.g. SmithP) of the user.
I will try to find the doc with Search and see if that works also scheduled. But it is still strange that GetDocumentByKey works differently when scheduled.
I will let you know if Search did work for me.
Subject: Scheduled lotusscript code never returns a document handle!
If you post all of your code, it will be easier to figure out what is wrong.
Subject: Scheduled lotusscript code never returns a document handle!
xRepository is it blank when run from the backend?
Use Msgbox or Print statements to dump statements to the log,
U could also use Remote Debugger, a bit of a pain to set up but very helpful
Subject: RE: Scheduled lotusscript code never returns a document handle!
Hi
xRepository is filled. I already placed printstatements to show this variable and it has always content.
Regards