About Me...

NotesRunningLogoRSmall.png

I'm Kathy Brown and I've been an application developer in Lotus Notes/Domino since 2005.

Prior to working in IT, I've had numerous careers including an Investment Analyst and even an Actress (long ago and far away).

And I (try to) love running!

me.jpg

kathy (at) runningnotes (dot) net

On Twitter, kjbrown13

Upcoming Races

Looking 4 Something?

Disclaimer

This is my personal blog. None of the opinions shown here represent those of my employer. In fact, forget I even have an employer. Any examples given here are strictly fictional and hypothetical and it is pure coincidence if they in any way seem like anything in real life.

« Running Secret | Main| Daydreaming about a Marathon and Running a Surprise 5k »

AutoUpdate a Notes View

Category Lotusscript
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

Gravatar Image1 - Hi, I think I'm blind. I can't find the RSS feed for this.

Help!

and, have a great day!

Gravatar Image2 - Ahem. You're not blind, I didn't add it. Links on the left now! :)

Gravatar Image3 - Thank you! I had faced that problem recently "Entry not found in index" and forgot about the autoupdate-problem. Going to check this today, which is probably the solution. Thank you for the reminder!

Gravatar Image4 - There are 2 situations where setting AutoUpdate off will save you: when someone else changes the index (as you said), and when YOU change the index.

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.

Gravatar Image5 - It's important to note that setting AutoUpdate = False will cause all other pending view reads and writes to queue up until the thread (e.g. an agent) that is holding the view has either released the view or set AutoUpdate = True.

This means that a long-running agent can "lock up" the view, causing other processes that want it to stall until it's done.

Gravatar Image6 - Another possibility is to select the documents you want into a DocumentCollection first. Of course if you modify them then you have to save them back.

Gravatar Image7 - One trick to avoid getting the wrong next document:
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

Emoticon stw

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)