Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lotus notes NotesDocument类中的parentView属性_Lotus Notes_Lotusscript_Lotus - Fatal编程技术网

Lotus notes NotesDocument类中的parentView属性

Lotus notes NotesDocument类中的parentView属性,lotus-notes,lotusscript,lotus,Lotus Notes,Lotusscript,Lotus,我有一个调用另一个函数的函数-骨骼如下所示 当第二个函数运行并到达“set doc=view.getNextDocument(doc)”行时,完全不相关的NotesDocument doc1上的parentView属性也会更新,从而打破原始循环 有什么想法吗 function getDept(){ dim doc1 as NotesDocument dim view1 as NotesView . . . set doc1 = view1.getFirstDocument whi

我有一个调用另一个函数的函数-骨骼如下所示

当第二个函数运行并到达“set doc=view.getNextDocument(doc)”行时,完全不相关的NotesDocument doc1上的parentView属性也会更新,从而打破原始循环

有什么想法吗

function getDept(){
 dim doc1 as NotesDocument
 dim view1 as NotesView
 .
 .
 .
 set doc1 = view1.getFirstDocument

 while not(doc1 is nothing)
 .
 .
 .
  call getDeptNumber()
 .
 .
 .
  set doc1 = view1.getNextDocument(doc1)

 }

 function getDeptNumber(){
  dim doc as NotesDocument
  dim view as NotesView
  .
  .
  .
  set doc = view.getFirstDocument

  while not(doc is nothing)
  .
  .
  .
   set doc = view.getNextDocument(doc)

  }
它快把我逼疯了

谢谢


Graeme

如果您运行视图,并且文档发生了更改(这些更改对视图产生了影响),那么第一个函数可能会出现问题

您最好使用集合来浏览文档

   function getDept(){
     dim doc1 as NotesDocument
     dim view1 as NotesView
     dim collEntries as NotesViewEntryCollection
     dim viewEntry as NotesViewEntry
     .
     .
     .
     set collEntries = view1.getAllEntries()
     set viewEntry = collentries.getFirstEntry

     while not(viewEntry is nothing)
     set doc1 = viewEntry.Document
     .
     .
      call getDeptNumber()
     .
     .
     .
      set viewEntry = collEntries.getNextEntry(viewEntry)

     }
    }

对其他函数使用相同的函数但是在删除集合中的文档时要小心

在没有看到更多代码的情况下有点不清楚,但我怀疑您的问题可能与缓存有关。如果从不同的视图访问同一个NotesDocument,则第二次和后续访问可能会使用代码另一部分内存中已有的同一文档。使用另一个答案中所示的视图条目集合可能会有所帮助。将视图的“自动更新”属性也设置为False

但我不得不注意到,您的代码组织得不是很好,效率也不是很高。看起来您的子例程(它没有参数,所以我假设它使用全局变量——如果可以避免的话,这是个坏主意)在每次调用它时都创建一个新的视图对象。那太贵了。此外,它似乎是为了查找值而在视图中进行迭代,这是低效的。使用排序视图,并使用视图方法搜索值


当您需要一个视图对象时,我建议您创建一个方法来获取它一次,并将其存储在类属性中,这样您就不必在数据库中多次搜索视图。

谢谢-让我摆脱困境!