Tired of trying to deal with Replication or Save Conflicts as response documents? This code converts conflict response documents found in a database to be main documents with a Conflict field set to "Yes". It also finds the main document involved in the conflict and sets the Conflict field to "Yes". This allows all documents associated with the conflict to be easily identified.
Dim session As New Notessession
Dim wk As New NotesUIWorkspace
Dim docdb As Notesdatabase
Dim conflictdoc, maindoc, nextdoc, targetdoc As NotesDocument
Dim conflictview, docview As NotesView
Dim delflag, maindocid As Variant
Set docdb = session.CurrentDatabase
'Conflicts view has a selection formula of SELECT @IsAvailable($Conflict) | (Conflict = "Yes")
'It will contain all conflict documents and main documents where conflicts have ocurred.
'It should have the "Show response documents in a hierarchy" flag unchecked.
Set conflictview = docdb.GetView("Conflicts")
conflictview.AutoUpdate = False
'DocsById view is sorted by @DocumentUniqueID
Set docview = docdb.GetView("DocsById")
Set conflictdoc = conflictview.GetFirstDocument
While Not(conflictdoc Is Nothing)
Set nextdoc = conflictview.GetNextDocument(conflictdoc)
If conflictdoc.Conflict(0) <> "Yes" Then
'Create new document and copy all fields
Set targetdoc = New NotesDocument( docdb )
Call conflictdoc.CopyAllItems( targetdoc, True )
'Remove fields defining the conflict
maindocid = targetdoc.GetItemValue("$Ref")
targetdoc.Conflict = "Yes"
Call targetdoc.Save(True, False)
'Remove the conflict response document
delflag = conflictdoc.Remove(True)
'Find the main document for this conflict and set Conflict flag to Yes
Set maindoc = docview.GetDocumentByKey(maindocid(0))
maindoc.Conflict = "Yes"
Call maindoc.Save(True, False)
Set conflictdoc = nextdoc