Replication Conflict View
Unlike other posted solutions, this model will allow the user to see both
replication conflict documents and their associated main (parent) document.
This is particularly useful when one is attempting to resolve replication
errors using "difference of two docs" as it puts the parent and child documents
in the same view.
*NOTE*
The author of this function is a college student from Virginia Tech interning
with Siecor. He has been working with Notes for only three months and is
already heading project development teams for Notes Databases. He is looking
for employment for this summer and beyond in Notes Development and System
Analysis. If you use this code or if you have any openings in these areas
please contact Andrew at AEye@vt.edu.
View Selection Formula:
Select (IsConflict = 1)
QueryOpen Event:
Sub Queryopen(Source As Notesuiview, Continue As Variant)
On Error Goto Proc_Error
'Declare database objects
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docConflict As NotesDocument
Dim docParent As NotesDocument
Dim dcConflict As NotesDocumentCollection Dim itemConflict As
NotesItem
Dim strErrorCode As String
Dim DateTime As New NotesDateTime( "01/01/1940" )
'date set sufficiently early to account for any possible documents
Set db = session.CurrentDatabase
Set dcConflict = db.Search( "@IsAvailable($Conflict)", DateTime , 0 )
'Search for replication conflicts by locating
'documents which contain the "$Conflict" field
'Add these documents to the dcConflict collection
For j = 1 To dcConflict.Count
'Loops through each document in the collection
Set docConflict = dcConflict.GetNthDocument(j)
docConflict.IsConflict = 1
'tags the document with the "IsConflict" field,
'value = 1
Call docConflict.Save( True, False)
strErrorCode = "No Parent"
'sets error code in case the document has no
'parent (orphaned replication conflict document)
Set docParent = db.GetDocumentByUNID _
( docConflict.ParentDocumentUNID )
'searches for the parent document of the conflict
'doc
docParent.IsConflict = 1
'tags the parent document with the "IsConflict"
'field, value = 1
Call docParent.Save( True, False )
Next
Initialize_Exit:
Exit Sub
Proc_Error:
'This error routine simply skips over orphaned
'replication conflicts. The conflict docs will
'not appear in the view UNLESS "show documents
'in a hierarchy" is UNCHECKED. One way around
'this problem is to change the orphaned
'replication conflicts to main docs by removing
'the $REF and $Conflict fields.
If strErrorCode = "No Parent" Then
Resume Next
End If
End Sub
*****************************************
Query Close Event: This function removes the tag from ALL documents. Without
this function, resolved conflicts will continue to appear in the view.
Sub Queryclose(Source As Notesuiview, Continue As Variant)
On Error Goto Proc_Error
Dim session As New NotesSession Dim db As NotesDatabase
Dim docConflict As NotesDocument
Dim dcConflict As NotesDocumentCollection
Dim itemConflict As NotesItem
Dim DateTime As New NotesDateTime( "01/01/1940" )
Dim strErrorCode As String
Dim intNoParentResponse As Integer
Dim strNoParentMessage As String
Set db = session.CurrentDatabase
Set dcConflict = db.Search( "@IsAvailable(IsConflict)", DateTime , 0 )
'Search for taged documents by locating documents
'which contain the "IsConflict" field
'Add these documents to the dcConflict collection
For j = 1 To dcConflict.Count
'Loops through each document in the collection
Set docConflict = dcConflict.GetNthDocument(j)
Set itemConflict = docConflict.GetFirstItem("IsConflict")
Call itemConflict.Remove
'Untags the document by removing the "IsConflict"
'field
Call docConflict.Save( True, False)
Next
Initialize_Exit:
Exit Sub
Proc_Error:
Resume Next
End Sub