Тема: Агент переноса документов в архив
Данный агент переносит документы с вьюхи admin_arc_allreg_2017 с формулой отбора
SELECT ((Form = "incoming") | (Form = "inside") | (Form = "outgoing")) & (@Contains(archive; "1"))& (!@Contains(responce; "1")) & (datereg<=[01/01/2018] ) & (datereg>=[01/01/2017] )
Все документы за 2017 год в базу documents2017.nsf.
При этом UniversalID в архиве и те что были в текущей базе - совпадают.
Dim session As New NotesSession
Dim db As NotesDatabase, workdb As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument, newdoc As NotesDocument
Dim server As String
'
Dim dc As NotesDocumentCollection
Dim ftdoc As notesdocument
Dim ftnewdoc As NotesDocument
Dim nextftdoc As NotesDocument
On Error Goto Errh
Set db = session.CurrentDatabase
server = db.Server
Set view=db.GetView("admin_arc_allreg_2017")
Set workdb = New NotesDatabase( server, "promdoc\documents2017.nsf" )
Set doc = view.GetFirstDocument
While Not (doc Is Nothing)
Set newdoc=workdb.CreateDocument
Call doc.CopyAllItems(newdoc,1)
newdoc.UniversalID=doc.UniversalID
Call newdoc.Save(True,False)
'' Start Answer
' находим все дочерние документы
Set dc = doc.Responses
Set ftdoc = dc.GetFirstDocument
While Not ftdoc Is Nothing
Set ftnewdoc=workdb.CreateDocument
Call ftdoc.CopyAllItems(ftnewdoc,1)
ftnewdoc.UniversalID=ftdoc.UniversalID
Call ftnewdoc.Save(True,False)
Set nextftdoc = dc.GetNextDocument (ftdoc )
Set ftdoc=nextftdoc
Set nextftdoc=Nothing
'Print ftdoc.UniversalID
Wend
nextDoc:
''End Answer
Set nextdoc = view.getnextdocument(doc)
Set doc=nextdoc
Set nextdoc=Nothing
Print doc.UniversalID & doc.header(0)
Wend
Exit Sub
Errh:
'
Print Error & | in line | & Erl(), 64, |Lotus Notes (| & Lsi_info(2) & |)|
Goto nextDoc
'Exit Sub