AutoUpdate a Notes View
While trying to diagnose a problem within an agent, I realized (with a little help-Thanks Bob!) that I needed to set the AutoUpdate flag on the view to False. The application is large and used by many different users concurrently. The view is changing almost constantly, even while the agent is running. Therefore running an agent on the view, particularly an agent that walks the view (GetFirstDocument, GetNextDocument), really needed to have the AutoUpdate turned off.
Okay, so somewhat obvious, eh? Well, maybe. I have a very poor memory, and constantly refer to the help files whenever coding in order to get the correct syntax on the first try. NOWHERE in the help files (at least in 8 or probably in 7, since that is what this app was created in) is the AutoUpdate flag referenced with regard to walking a view. Help for GetNextDocument? Nope, not mentioned there. Not even a mention in the help document titled, "Locating documents within a view or folder in LotusScript classes".
At least in the small amount of other dev's code that I have reviewed, I do not see AutoUpdate being set to false very frequently. Further investigation provides this best practice setting from Andre Guirard. Which, if you don't feel like going to read it, basically states that it's a good idea to set AutoUpdate to false for a couple of reasons. There are also a couple of reader comments on the lack of documentation.
So, I post this in the hopes that some other newbie out there reads this and starts using notesview.AutoUpdate = False in their agents. It'll help performance, and hopefully avoid errors as well.
Comments
Help!
and, have a great day!
Posted by Rick VanGameren At 12:13:10 On 28/04/2009 | - Website - |
Posted by Kathy Brown At 12:43:13 On 28/04/2009 | - Website - |
Posted by Marcus Foerster At 22:35:31 On 28/04/2009 | - Website - |
When AutoUpdate is off, view navigation (e.g., GetNextDocument) is always relative to the existing position of the "current" document. Your code is essentially using a static copy of the view index.
When AutoUpdate is on, the view index is refreshed before navigation happens (if the view needed refreshing), so the "next" document you get will be relative to the NEW position of the current document in the view.
If someone else changes the view, and if you have AutoUpdate on, your "next" document may be an unexpected one. If, as a result of the change, your current document is moved up, the next one you get may be one you've seen before.
The other thing to watch out for is when you modify the current document in a way that affects where it is in the view (e.g., change a data item that is used to sort or categorize). Suddenly (if you don't turn AutoUpdate off) your "current" document is in a completely different spot, and you might get surprising results.
Posted by Bob Balaban At 04:42:49 On 29/04/2009 | - Website - |
This means that a long-running agent can "lock up" the view, causing other processes that want it to stall until it's done.
Posted by Erik Brooks At 07:07:24 On 29/04/2009 | - Website - |
Posted by RobShaver At 15:24:02 On 30/04/2009 | - Website - |
Dim doc as NotesDocument
Dim nextDoc as NotesDocument
Set doc = view.getFirstDocument
Do until doc is Nothing
set nextDoc = view.getNextDocument(doc)
.... do what you have to do ....
set doc = nextDoc
Loop
Posted by Stephan H. Wissel At 23:59:58 On 05/05/2009 | - Website - |