LotusScript代理不起作用

时间:2012-02-22 16:57:42

标签: lotus-notes agent lotusscript

我遇到了这个代理的问题 - 我在类似的代理中使用了完全相同的技术,但出于某种原因,客户端报告了此行的错误:

Set dc = locView.GetAllDocumentsByKey(key, True)

它表示未设置对象变量。你能帮我找到我错过的东西吗?

提前致谢。

%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

End Sub

1 个答案:

答案 0 :(得分:3)

这条线很可能失败了:

Set locView = locDb.GetView("byNameDateLocCode")

您在调试器中看到了什么?如果它不是有效视图,请检查视图名称以确保它与上述内容匹配,并检查数据库ACL和视图的任何限制以确保您具有所需的权限。如果代理程序作为Web代理程序运行,请确保签名者和/或服务器具有所需的权限(具体取决于代理程序运行时标识的设置)。如果数据库locDb与运行代理程序的服务器位于不同的服务器上,请确保目标服务器为代理服务器授予“可信服务器”权限。