LotusScript 代理不工作

发布于 2025-01-08 06:43:47 字数 1888 浏览 0 评论 0原文

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

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

结束子

I am having issues with this agent - i have used the exact same technique in a similar agent but for some reason, the client is reporting an error with this line:

Set dc = locView.GetAllDocumentsByKey(key, True)

It says that the object variable is not set. Can you help to find what I am missing?

Thanks in advance.

%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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋风の叶未落 2025-01-15 06:43:47

这行很可能失败:

Set locView = locDb.GetView("byNameDateLocCode")

What do you see for locView in the debugger?如果它不是有效的视图,请检查视图名称以确保其与上述内容匹配,并检查数据库 ACL 和视图的任何限制以确保您具有所需的权限。如果代理作为 Web 代理运行,请确保签名者和/或服务器具有所需的权限(取决于代理运行时身份的设置)。如果数据库 locDb 与运行代理的服务器位于不同的服务器上,请确保目标服务器授予代理服务器“受信任的服务器”权限。

Most likely this line is failing:

Set locView = locDb.GetView("byNameDateLocCode")

What do you see for locView in the debugger? If it is not a valid view, check the view name in order to make sure it matches the above, and check the database ACL and any restrictions on the view to make sure that you have the required permissions. If the agent is running as a web agent, make sure that the signer and/or the server has the required permissions (depending on your setting for the agent's runtime identity). If the database locDb is on a different server than the one where the agent is running, make sure that the agent server is granted 'Trusted Server' rights by the target server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文