The following snippet of code is located in a hidden field at the top of a document. Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim Doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set Doc = uidoc.Document
This code has worked fine in 5.0, but in 6.5 it fails with “Object not set” because uidoc is null. Is this a known bug?
Thanks!
Subject: Working script in 5.0 fails in 6.5
What event is this code located in ?
Subject: RE: Working script in 5.0 fails in 6.5
The script is in the initialize event of the first field of a document. It is quite a lengthy script that searches other documents in the database and develops the amount paid or credited on the invoice (this doc). When run in 5.0, the uidoc does contain an object that represents the invoice doc; in 6.5, the uidoc is null and causes the “Set Doc = uidoc.document” statement to fail.
Thanks again for your help!
Subject: RE: Working script in 5.0 fails in 6.5
I would have put that in the PostOpen event of the form, not in a Field event. It could be that the “UIDoc” is not ready for use durring Initalize events ? (That’s a guess)
In PostOpen, you have the UIDoc fully build and ready for use, which is why it might be a better place for this sort of thing.
Subject: RE: Working script in 5.0 fails in 6.5
Thanks again for your help! I agree that when the PostOpen event fires the UIDoc would be fully built. Unfortunately, the results of this script need to be diplayed on the UIDoc. And, if this script completes, there are two more scripts (which I had not mentioned before) that calculate resluts to be displayed on the UIDoc. I guess I am still puzzled why this document works very well in Notes 5.0 and fails in Notes 6.5.
Subject: RE: Working script in 5.0 fails in 6.5
Unless you are working with Rich Text Fields, PostOpen will work fine, as when you update the backend NotesDocument, the frontend NotesUIDocument will automatically update as well. (And visa-versa)
Subject: Where does it fail?
It works fine behind an action button in 6.03. Can you provide more information how & where it’s being used?
Subject: RE: Where does it fail?
The script is in the initialize event of the first field of a document. It is quite a lengthy script that searches other documents in the database and develops the amount paid or credited on the invoice (this doc). When run in 5.0, the uidoc does contain an object that represents the invoice doc; in 6.5, the uidoc is null and causes the “Set Doc = uidoc.document” statement to fail.
Thanks again for your help!
Subject: Working script in 5.0 fails in 6.5
The script is in the initialize event of the first field of a document. It is quite a lengthy script that searches other documents in the database and develops the amount paid or credited on the invoice (this doc). When run in 5.0, the uidoc does contain an object that represents the invoice doc; in 6.5, the uidoc is null and causes the “Set Doc = uidoc.document” statement to fail.
Thanks again for your help!