您的位置:程序门 -> 企业开发 -> lotus



读者域赋值问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


读者域赋值问题[已结贴,结贴人:lucern]
发表于:2007-06-20 10:02:05 楼主
一篇待办事宜,本来是a的,现在想让b也能看到
因为是分类视图显示,key列是to域
所以,我把to从单值域改为了多值域,然后写了一个代理
key   =     "a "
set   view   =   db.getview   ( "dbsy "   )
set   doc   =   view.getdocumentbykey   (key)
然后
i=1
while   not(doc   is   nothing)    
                      if   doc.to(0)= "a "   then
                            tt=evaluate( "@setfield( 'to ';to: 'b ') ",doc)
          tt=evaluate( "@setfield( 'reader ';readere: 'b ') ",doc)
                            call   doc.save(true,   true   )
                            msgbox   i
                      end   if
                      set   doc   =   view.getnextdocument(doc)  
                      i=i+1
wend
i   msg出来的数目是对的,可是程序运行完以后,b登录进入只能看到部分a的待办事宜,而不是全部,不知道到底是哪里出了问题,大家有没有更好的建议?实在不明白到底哪里出了问题,很郁闷。
发表于:2007-06-20 11:01:411楼 得分:0
发现是有的读者域赋值不进去......有什么其他赋值方法么?
发表于:2007-06-20 11:18:082楼 得分:20
dim   itemreaders   as     new   notesitem(doclog, "readers ", " ")
itemreaders.isreaders=true
set   nam   =   new   notesname(b)
call   itemreaders.appendtotextlist(cstr(nam.canonical))
call   doc.save(true,false)
发表于:2007-06-20 14:10:453楼 得分:0
dim   itemreaders   as     new   notesitem(doclog, "readers ", " ")
itemreaders.isreaders=true
set   nam   =   new   notesname(b)
call   itemreaders.appendtotextlist(cstr(nam.canonical))
/*to   field   add   b   too*/
set   item=doc.getfirstitem( "to ")
call   item.appendtotextlist(nam.canonical)
call   doc.save(true,false)
发表于:2007-06-20 15:54:594楼 得分:0
谢谢漂浮的云,不过你给的代码不能直接用,我又改了一下,然后对单个文档的时候我是这么写的:
dim   doc   as   notesdocument
set   doc=session.documentcontext
forall   i   in   doc.items
if   item.isreaders   then
set   nam   =   new   notesname( "b ")
call   i.appendtotextlist(cstr(nam.canonical))
call   doc.save(true,false)
end   if
end   forall
exit   sub
果然是好的,没有问题。
但是,我又改了一下,因为我要取一组document,然后在reader域里面增加b的值,如下:
dim   session   as   new   notessession  
dim   db   as   notesdatabase  
dim   collection   as   notesdocumentcollection
dim   doc   as   notesdocument
set   db   =   session.currentdatabase
set   collection   =   db.alldocuments
dim   dc   as   notesdocumentcollection
dim   view   as   notesview
key   =     "a "
set   view   =   db.getview   ( "dbsy "   )
set   dc   =   view.getalldocumentsbykey(key,   false)
set   doc   =   dc.getfirstdocument()
i=1
while   not(doc   is   nothing)    
tt=evaluate( "@setfield( 'to ';to: 'b ') ",doc)
forall   i   in   doc.items
if   item.isreaders   then
set   nam   =   new   notesname( "b ")
call   item.appendtotextlist(cstr(nam.canonical))
end   if
end   forall
call   doc.save(true,   true   )
set   doc   =   dc.getnextdocument(doc)  
i=i+1
wend
exit   sub
但是运行的时候forall   i   in   doc.items一行报错说no   resume,不知道是不是我doc取的不对还是我少定义了什么呢?
发表于:2007-06-20 16:44:055楼 得分:0
forall   alias   variable   was   previously   declared:i
发表于:2007-06-21 09:14:136楼 得分:0
i重复定义了,改成这样:
dim   session   as   new   notessession
dim   db   as   notesdatabase
dim   collection   as   notesdocumentcollection
dim   doc   as   notesdocument
set   db   =   session.currentdatabase
set   collection   =   db.alldocuments
dim   dc   as   notesdocumentcollection
dim   view   as   notesview
key   =   "a "
set   view   =   db.getview   ( "dbsy "   )
set   dc   =   view.getalldocumentsbykey(key,   false)
set   doc   =   dc.getfirstdocument()
i=1
while   not(doc   is   nothing)
tt=evaluate( "@setfield( 'to ';to: 'b ') ",doc)
forall   v   in   doc.items
if   v.isreaders   then
set   nam   =   new   notesname( "b ")
call   item.appendtotextlist(cstr(nam.canonical))
end   if
end   forall
call   doc.save(true,   true   )
set   doc   =   dc.getnextdocument(doc)
i=i+1
wend
exit   sub
发表于:2007-06-21 10:01:517楼 得分:0
err,我发现我总是犯低级错误,太丢脸了> _ <
谢谢


快速检索

最新资讯
热门点击