I have an agent that is called by a user’s click of a button on a document. The agent is called with the .RunOnServer( str_NoteID ) type call. The str_NoteID is the NoteID of the current document.
Once the agent starts, it uses a script library I’ve set up which has global variables for the NotesSession and NotesDatabase. In the agent’s initialize, I call a function within the library and pass the NotesDocument I obtained with nagt_Cur.ParameterDocID and ndb_Cur.GetDocumentByID. In print statements I see that the document is obtained. However, when I call the function and pass this document, a print statement shows the document was NOT passed.
I am guessing that is due to a scope issue, however, since I am using a global variable for the database, should it not be in scope?
It is very frustrating having to pass so many parameters, when this should work, I would think.
Subject: Question about Scope of Objects & LotusScript
There was something wierd with script libraries and NotesDatabase instances. It could be that your NotesDatabase variable gets lost when you pass it between the agent’s functions and the script library.
Subject: RE: Question about Scope of Objects & LotusScript
I am not actually passing it. I declare it in the library as global, and initialize it in the library’s initialize event. Then all the other routines and functions use it. And it doesn’t error anywhere. Just the one pass of a document doesn’t work. I also successfully pass a different document to a different function, with basically the same code. Very weird. No typos, either.
Subject: RE: Question about Scope of Objects & LotusScript
Actually the problem was with NotesDocument, and not NotesDabatase, but I can’t really remember when and what the problem was, the NotesDocument value just got lost when passing to a function in a script library, if I remember correctly.
Anyway, you should now find the problem pretty easily, if you say that it works for one document, but not for another. How do the documents differ, are they in different databases, do you really have the document opened, so that you can see all it’s fields in the debugger, or just a dummy instance (which happens when documents are corrupted or protected by readers fields).