我遇到了这个代理的问题-我在一个类似的代理中使用了完全相同的技术,但由于某些原因,客户端报告了以下代码行的错误:
Set dc = locView.GetAllDocumentsByKey(key, True)它说明object变量未设置。你能帮我找找我遗失的东西吗?
提前谢谢。
%REM
Sub as_archiveOldDocuments
Description:
This agent archives documents that are more than one week old.
This is so that the dataset used is kept current - view selections only select documents
whose archived field value is equal to zero. For that reason, this agent detects whether
or not a document in the set is more than a week old. If it is, the Archived field is
marked as '1'.
Function calls: N/A
Sub calls: N/A
Called in event: N/A
Called by: ag_archiveOldDocuments
%END REM
Public Sub as_archiveOldDocuments
Dim s As NotesSession
Dim locDb As New NotesDatabase(****)
Dim locView As NotesView
Set locView = locDb.GetView("byNameDateLocCode")
Dim dc As NotesDocumentCollection
'Set dc = locDb.CreateDocumentCollection()
Dim key (0 To 1) As Variant
Dim archiveDate As NotesDateTime
Set archiveDate = New NotesDateTime(Today)
Call archiveDate.AdjustDay(-7)
Dim thisDoc As NotesDocument
Dim unarchived As Integer
Let unarchived = "0"
'populate key to build document collection, then build it
key(0) = archiveDate.DateOnly
key(1) = unarchived
Set dc = locView.GetAllDocumentsByKey(key, True)
'find first document in the collection
Set thisDoc = dc.GetFirstDocument()
'while the doc collection exists
While Not dc Is Nothing
'if the date value in the document is less than the archiveDate value specified (today -7)
If thisDoc.Date <= archiveDate.DateOnly Then
'replace the archived value (which will be '0') with '1'
Call thisDoc.ReplaceItemValue("Archived", "1")
Call thisDoc.ComputeWithForm(False,True)
Call thisDoc.Save(True, False, False)
End If
Set thisDoc = dc.GetNextDocument(thisDoc)
Wend结束子对象
发布于 2012-02-23 03:41:20
最有可能的情况是这一行失败了:
Set locView = locDb.GetView("byNameDateLocCode")您在调试器中看到的locView是什么?如果不是有效的视图,请检查视图名称以确保其与上述内容匹配,并检查数据库ACL和对视图的任何限制,以确保您具有所需的权限。如果代理作为web代理运行,请确保签名者和/或服务器具有所需的权限(取决于您对代理的运行时标识的设置)。如果数据库服务器与运行代理的服务器位于不同的服务器上,请确保目标服务器授予代理服务器“Trusted locDb”权限。
https://stackoverflow.com/questions/9399338
复制相似问题