У меня проблемы с этим агентом - я использовал точно такой же метод в аналогичном агенте, но по какой-то причине клиент сообщает об ошибке с этой строкой:
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