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
Wend

This was first published in March 2001

Dig deeper on Domino Resources - Part 3

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close