We have a Visual Basic project accessing Notes via OLE. We use Notes classes in VB for accessing Notes form, modify and saving field values. A piece of VB code allows us to change a value field in a Notes form and save it. So before the change, the field has an OLDVALUE; after the change, it has a NEWVALUE. (We see the document field value directly in a view in the Notes database.)
In the same VB project, another piece of VB code reads the same form/field (using Notes classes). But the thing is: The field value reads=OLDVALUE! It seems the OLE call ...getodocumentByunid("...") in VB isn't physically reading the form in the database but is reading cached old values instead.
We've done a lot of debugging but can't find anything wrong in our code. Any suggestions?
You're exactly correct that Notes maintains a cache of NotesDocument objects in memory. Use the Delete statement to clear NotesDocument objects from the cache when you're done with them. That way, code that you execute later is assured of getting the latest document from the file, not a previously cached copy.
I also face this problem, but I don't understand how to "Use the Delete statement to clear NotesDocument objects from the cache"; is it VB function or Notes function? If it's a VB function, would you mind to show a piece of VB code to show how to clear NotesDocument object?
Here's a good way to loop through a series of documents and prevent them from accumulating in the cache. This works exactly the same in LotusScript or VB.
Set docCur = view.GetFirstDocument( ) Do Until docCur Is Nothing Set docNext = view.GetNextDocument(docCur) ' process docCur here Delete docCur ' done with it -- remove from cache Set docCur = docNext Loop
Do you have comments on this Ask the Expert question and response? Let us know.
Dig Deeper on LotusScript
Related Q&A from Andre Guirard
Learn how you can use LotusScript and OLE to create and populate Microsoft Excel spreadsheets, as well as a little bit about Lotus Symphony. Continue Reading
Discover options you can use if you'd like external users to be able to access a workflow-based Notes Domino application through different ... Continue Reading
Learn why you may receive the error message: "Illegal circular use: Audit Trail" when trying to open Lotus Notes documents that use copied forms. Continue Reading