Manage Learn to apply best practices and optimize your operations.

Archive All Documents Excepting Conflict Documents And Their Parent(S)

I had a requirement to periodically archive all documents in a view to a backup
database and delete those archived docs. from the current database.

The trick was that the users wanted all documents to be archived excepting
Replication/Save Conflicts documents along with their parents. The users wanted
the final authority to decide which among the conflict document is the winner
and that they should be able to do at any time.
Assume you have a view (View 1) which shows all documents with the view
property 'Show Response documents in a hierarchy' enabled. This will display
all documents and their responses, including Conflict documents as responses to
their parent(s).

Here is what we do :

Create a view 'View 2' which will only show the parent documents including the
view selection formula :

!@IsResponseDoc(not to display response documents)

Then create an Agent 'Archiving Agent' which runs on all documents in View 2
and insert this piece of script in it.

Sub Initialize

Dim db As New NotesDatabase( Server, SourceDbName )
Dim ArcDb As New NotesDatabase ("", ArchiveDbName)
Dim doc As NotesDocument
Dim PrevDoc As NotesDocument
Dim collection As NotesDocumentCollection
Dim currentResponse As NotesDocument

Dim view As Notesview
Set view = db.GetView( "View 2" )

Dim Conflict As String

' Set the doc and prevdoc pointers initially to the first document in the
view
Set doc = view.GetFirstDocument
Set prevdoc = view.GetFirstDocument

' Loop until EOView
While Not ( doc Is Nothing )

Set collection = doc.Responses
Conflict = "NO"

If collection.count > 0 Then

Set currentResponse = collection.GetFirstDocument
Do While Not ( currentResponse Is Nothing )

' Scan and ensure none of the responses are conflicts
For j = 1 To collection.Count
Set currentResponse = collection.GetNthDocument( j )
If currentResponse.HasItem("$Conflict")
Then
Conflict = "YES"
Exit For
End If
Next

' If there are no Conflicts in the collection
If Conflict = "NO" Then

For j = 1 To collection.Count
Set currentResponse = collection.GetNthDocument(
j )
Call currentResponse.CopyToDatabase( ArcDb )
Next
Call doc.CopyToDatabase( ArcDb )

Else
Exit Do
End If

Loop

Else
Call doc.CopyToDatabase( ArcDb )
End If

Set doc=view.GetNextDocument (doc)
If Conflict <> "YES" Then
Call prevdoc.Remove(True)
End If
Set prevdoc = doc

Wend

' Messagebox "Display your Message here", MB_OK, "Archived Documents"

End Sub

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close