Manage Learn to apply best practices and optimize your operations.

Converting Replication/Save Conflicts to Documents

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
Call targetdoc.RemoveItem("$Conflict")
maindocid = targetdoc.GetItemValue("$Ref")
Call targetdoc.RemoveItem("$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)
End If
Set conflictdoc = nextdoc

Dig Deeper on Domino Resources - Part 3



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury