有一个代理可以将文档归档到归档数据库中,并将其从当前数据库中删除,但是当我运行该代理时,一些文档会被归档,归档会停止,并出现错误"Archiving Pending Requests:4000:Line 33:User-defined error“
Option Public
'Use "LogError"
Sub Initialize
On Error Goto errorHandler
Dim s As New NotesSession
Dim Odb As NotesDatabase
Dim Oview As NotesView
Dim Oview2 As NotesView
Dim archdb As NotesDatabase
Dim archdbpath As String
Dim Ovc As NotesViewEntryCollection
Dim doc As NotesDocument
Dim archview As NotesView
Set Odb = s.CurrentDatabase
archdbpath = "Archiving\Archive2_DunkMatMaint911.nsf"
Set archdb = s.GetDatabase("BRUSPLNA101", archdbpath, False)
If Not(archdb.IsOpen()) Then
'Logaction "Could not locate Archive database "
Msgbox "Could not locate Archive database "
Exit Sub
End If
'Set archview = archdb.GetView("vw_InArchivedDB")
Set Oview = Odb.GetView("Archive Requests 1") '----Archiving View Name
Msgbox "Going In While Loop"
Set doc = Oview.GetFirstDocument()
While Not(doc Is Nothing)
Call doc.CopyToDatabase(archdb)
doc.Archived = "True"
Call doc.Save(True, False)
Call Oview.Refresh
Set doc = Oview.GetFirstDocument()
Wend
Set Oview2 = Odb.GetView("Archive Requests 2")
Call Oview2.Refresh
Set Ovc = Oview2.AllEntries
Exit Sub
errorHandler:
'LogAction("Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) )
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err)
End Sub发布于 2020-10-22 22:21:15
幸运的是,您的代码有一个错误处理程序...因此,我们确切地知道这个错误发生在哪一行:
Call doc.Save(True, False) 这意味着:代码所处理的文档不能保存。
遗憾的是,错误号4000是一个一般性错误,可能意味着很多事情。我猜,在您的情况下,文档已经变得很大(一个字段中的数据超过32k),因此无法保存。
我会以这种方式更改代码,使其写入有关无法存档的文档的日志,并继续下一个文档,而不是崩溃。因此,您还需要更改逻辑,因为如果无法保存文档,它将永远不会从视图中消失:
Dim viwNav as NotesViewNavigator
Dim ve as NotesViewEntry
Set viwNav = Oview.CreateViewNavigator()
Oview.AutoUpdate = False
Set ve = viwNav.GetFirst()
While Not(ve Is Nothing)
Set doc = ve.Document
On Error Goto errorHandlerDoc
Call doc.CopyToDatabase(archdb)
doc.Archived = "True"
Call doc.Save(True, False)
NextDoc:
Set ve = viwNav.GetNext(ve)
Wend
On Error Goto errorHandler
Set Oview2 = Odb.GetView("Archive Requests 2")
Call Oview2.Refresh
Set Ovc = Oview2.AllEntries
Exit Sub
errorHandlerDoc:
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) + " for document " + doc.UniversalId
Resume NextDoc
errorHandler:
'LogAction("Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) )
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) https://stackoverflow.com/questions/64480777
复制相似问题