Hi,
I’m looping a view (selection form=“tipo1”) with a NotesViewNavigator
and i create a new document with diferent form, and the getnextdocument are pumping one entry in the view.
when i use the autoupdate=false it works ok.
Dim view As NotesView
Set view = db.GetView( “Vista01” ) ’ Form = “tipo1”
Dim nav As NotesViewNavigator
Set nav = view.CreateViewNav()
Dim entry As NotesViewEntry
Set entry = nav.GetFirst
While ( Not entry Is Nothing )
Dim doc As notesdocument
Set doc = New NotesDocument (db)
doc.Form = "otro2"
Call doc.Save( True, False)
set entry = nav.GetNextDocument( entry )
Wend
I think that this’s a bug?
If the document that i create is not in the view selection, the view must be the same!
And if any one create a document (that don’t match de selection of the view) while the script is running in an agent?
thanks,
Subject: NotesViewNavigator GetNextDocument GetNext bug?
Just a note on the line:
entry = nav.GetNextDocument( entry )
You are missing “set”:
Set entry = nav.GetNextDocument( entry )
I don’t know if this is related to your problem. Or just a typo in cutting and pasting the code.
Leonardo Prizont
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
Yes a cut and paste, the code showed is to ilustrate the problem 'cause the code is more large.
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
When you save a document, you affect its position and/or membership in the view. It makes sense that if you use GetNextXxx after that, there might be some unexpected results, because the next entry now is not the same as the next entry then.
What I believe is happening, is that the collection object remembers the ID of the last entry it returned, and if the entry it is passed is the same one, it adds one to the view position and returns the entry at that position. But if the document represented by the old entry is gone from the view, then the document that used to be “next” is now at the position previously occupied by the document you just saved – so its view position is one less, and the document following it is processed instead.
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
but the document that is being created don’t belongs to the view and don’t affect the visible results of the view, but it seems that affect to the object representation. I think this is not correct.
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
If you would show your actual code, someone might be able to pinpoint exactly what’s happening, but I have to suspect that besides creating a new document, you’re also modifying the document you get from the view. At any rate, you have a way to get it to work the way you want.
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
thanks for your time, i understand that the way i must follow is to put view.AutoUpdate = False
but, this means that i must put this line everywhere i do a loop into a view, in order to avoid an error when “any” document is created on the client and this agent is running on a server.
Thanks again,
Subject: RE: NotesViewNavigator GetNextDocument GetNext bug?
It is advisable, yes. As with any best practice, it’s a lot easier to do it when you write the code initially.
If you need help finding all the places in your applications where you might want to do this, perhaps this download would be helpful: Design element search