Comparing fields in replication conflict documents

Script to compare fields in replication conflict documents

The script below is a "Quick and Dirty" piece of code that will look at replication conflict documents and compare each field to determine if it's different.

It then creates an email of ALL replication conflicts identifying the field(s) that are different between the parent and replication conflict. The email includes doclinks to the parent and to the replication conflict.

You need 2 things:
1. a view that shows only replication conflicts. Then put the code below into a view Action button.

2. a form containing 3 fields in a 3 column table. Text1 (Text), Text2(richtext), and text3(richttext).

Currently only the text value of RichText fields is compared. The code can be enhanced to look for other differences in RichText fields such as attachments etc. As well, as ignoring certain fields.

Hope you find it useful.


Sub Initialize Dim session As New NotesSession Dim ws As New NotesUIWorkspace Dim db As NotesDatabase Dim view As NotesView Dim pdoc As NotesDocument Dim rdoc As NotesDocument Dim renderdoc As NotesDocument ' Dim item As NotesItem Dim rtitem1 As NotesRichtextItem Dim rtitem2 As NotesRichtextItem Dim rtitem3 As NotesRichtextItem Dim item1 As Variant Dim item2 As Variant Dim itemType1 As Integer Dim itemType2 As Integer Dim success As Variant Dim thefield As Variant Dim richStyle As NotesRichTextStyle Set richStyle = session.CreateRichTextStyle richStyle.FontSize = 8 Set db = session.CurrentDatabase Set view = db.GetView(".vwAdminRepConflicts") Set rdoc = view.GetFirstDocument If rdoc Is Nothing Then Beep Msgbox("No Replication Conflicts Found") Exit Sub End If rdocctr = 0 'Create the email with the heading stuff Dim emaildoc As New NotesDocument(db) emaildoc.Form = "Memo" emaildoc.SendTo = session.UserName Set rtitem1 = New NotesRichTextItem(emaildoc,"Body") Set renderdoc = New NotesDocument(db) Do While Not rdoc Is Nothing rdocctr = rdocctr + 1 Set pdoc =db.GetDocumentByUNID(rdoc.Parentdocumentunid) Set renderdoc = New NotesDocument(db) renderdoc.Form = ".rptRepConflicts" Set rtitem2 = New NotesRichTextItem(renderdoc, "Text2") Set rtitem3 = New NotesRichTextItem(renderdoc, "Text3") Call rtitem2.AppendStyle(richStyle) Call rtitem3.AppendStyle(richStyle) Call rtitem2.AppendText("Parent for form: " & pdoc.GetItemValue("Form")(0) & " -->") Call rtitem3.AppendText("Conflict for form: " & rdoc.GetItemValue("Form")(0) & " -->") Call rtitem3.AppendDocLink(rdoc,"") If pdoc Is Nothing Then Call rtitem2.AppendText("Not Found") Call renderdoc.ComputeWithForm(False,False) Call rtitem1.AddNewLine(2) success = renderdoc.RenderToRTItem(rtitem1) 'just one line with doc link and saying there's no parent 'include form name Else Call rtitem2.AppendDocLink(pdoc,"") Call renderdoc.ComputeWithForm(False,False) Call rtitem1.AddNewLine(2) success = renderdoc.RenderToRTItem(rtitem1) i = 0 Set renderdoc = New NotesDocument(db) renderdoc.Form = ".rptRepConflicts" Forall item In rdoc.Items thefield = Ucase(Item.Name) If thefield <> "$REF" And thefield <> "$CONFLICT" Then If Not pdoc.HasItem(thefield) Then renderdoc.Text1 = item.name Set rtitem2 = New NotesRichTextItem(renderdoc, "Text2") Set rtitem3 = New NotesRichTextItem(renderdoc, "Text3") Call rtitem2.AppendStyle(richStyle) Call rtitem3.AppendStyle(richStyle) Call rtitem2.AppendText("FIELD NOT AVAILABLE") Call rtitem3.AppendText(rdoc.GetItemValue(thefield)(0)) Call renderdoc.ComputeWithForm(False,False) success = renderdoc.RenderToRTItem(rtitem1) Set renderdoc = db.CreateDocument Set renderdoc = New NotesDocument(db) renderdoc.Form = ".rptRepConflicts" Else text1 = "" text2 = "" theerror = False Set item1 = rdoc.GetFirstItem(thefield) Set item2 = pdoc.GetFirstItem(thefield) If item1.Type = RICHTEXT Then If item1.text <> item2.text Then theerror = True text1 = item1.text text2 = item2.text Else theerror = False End If Else If item1.values(0) <> item2.Values(0)Then theerror =True text1 = item1.Values(0) text2 = item2.Values(0) Else theerror = False End If End If If theerror Then renderdoc.Text1 = item.name Set rtitem2 = New NotesRichTextItem(renderdoc, "Text2") Set rtitem3 = New NotesRichTextItem(renderdoc, "Text3") Call rtitem2.AppendStyle(richStyle) Call rtitem3.AppendStyle(richStyle) Call rtitem2.AppendText(text1) Call rtitem3.AppendText(text2) Call renderdoc.ComputeWithForm(False,False) success = renderdoc.RenderToRTItem(rtitem1) Set renderdoc = db.CreateDocument Set renderdoc = New NotesDocument(db) renderdoc.Form = ".rptRepConflicts" End If End If End If End Forall End If Set rdoc = view.GetNextDocument(rdoc) Loop Call rtitem1.AddNewLine(2) Call rtitem1.AppendStyle(richStyle) Call rtitem1.AppendText("TOTAL Replication Conflicts = " & rdocctr) Call emaildoc.Send(False) Msgbox("TOTAL Replication Conflicts = " & rdocctr) End Sub
This was last published in September 2001

Dig Deeper on Domino Resources - Part 3

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