视图的搜索条件里的字段和代理里改变的字段是同一个字段,代理执行完视图里的数据会变动。现在代理能执行了,就是不能多次循环,视图里好多数据,每次执行代理只循环两次
Set Curdoc =view.Getfirstdocument()
While Not (Curdoc Is Nothing )
Call Curdoc.Replaceitemvalue("Status_Num","100")
(Status_Num是改变的字段,也是视图的搜索条件)
Set Curdoc = view.Getnextdocument(Curdoc)
Wend
不应该这样做,应该引入一个temp变量来保存下一个文档的指向,
doc=view.getfirstdocument()
dim tmpdoc as notesdocument
while not doc is nothing
set tmpdoc=view.getnextdocument(doc)
'do sth with doc
set doc=tmpdoc
wend
可能视图索引更新或者文档已经被移除。
1、代码执行时延迟更新:NotesDatabase.AutoDelayUpdates=True
2、使用NotesViewEntryCollection集合进行遍历,
NotesViewEntry中的IsValid属性可以判断当前入口是否有效。
3、使用临时变量方式循环。
入口集合:
Set nextEntry=ec.getNextEntry(entry)
...
Set entry=nextEntry
文档:
Set nextDoc=NotesView.GetNextDocument(doc)
...
Set doc=nextDoc
文档集合:
Set nextDoc=NotesDocumentCollection.getNextDocument(doc)
...
Set doc=nextDoc
有大神推荐的方法:
1、代码执行时延迟更新:NotesDatabase.AutoDelayUpdates=True 2、使用NotesViewEntryCollection集合进行遍历, NotesViewEntry中的IsValid属性可以判断当前入口是否有效。 3、使用临时变量方式循环。 入口集合: Set nextEntry=ec.getNextEntry(entry) ... Set entry=nextEntry 文档: Set nextDoc=NotesView.GetNextDocument(doc) ... Set doc=nextDoc 文档集合: Set nextDoc=NotesDocumentCollection.getNextDocument(doc) ... Set doc=nextDoc
这些都试过了,不起作用,先循环文档总数的一半,然后逐次递减。。。。。