Remove Duplicate Address Book Documents

The user won't tell me how it happened, but between a botched import from a
WordPerfect mail merge file and a misfiring Palm Pilot he and his secretary
managed to duplicate most of the docs in his Personal Address Book. He now has
over 6000 docs. and at least 2500 are duplicates. I found Purna Sukhadia's
script here and modified it to brute-force delete any PAB doc with matching
first name, last name, company name, office phone number, mail address, and
business address. Ugly code and not very elegant in execution but easily
modified to suit your own purposes.

Copy and paste the code in your agent.
Sub Initialize
Dim s As New notessession
Dim db As notesdatabase
Dim doc1 As notesdocument
Dim doc2 As notesdocument
Dim view As notesview
Dim tempFirstName1 As Variant
Dim tempLastName1 As Variant
Dim tempOfficePhoneNumber1 As Variant
Dim tempCompanyName1 As Variant
Dim tempMailAddress1 As Variant
Dim tempBusinessAddress1 As Variant
Dim tempFirstName2 As Variant
Dim tempLastName2 As Variant
Dim tempOfficePhoneNumber2 As Variant
Dim tempCompanyName2 As Variant
Dim tempMailAddress2 As Variant
Dim tempBusinessAddress2 As Variant
Dim dupeCtr As Variant
Dim dc As NotesDocumentCollection

Set db=s.currentdatabase
Set dc = db.AllDocuments
Set doc1 = dc.GetFirstDocument()
Set doc2 = dc.GetFirstDocument()

tempFirstName1=""
tempLastName1=""
tempOfficePhoneNumber1=""
tempCompanyName1=""
tempMailAddress1=""
tempBusinessAddress1=""
tempFirstName2=""
tempLastName2=""
tempOfficePhoneNumber2=""
tempCompanyName2=""
tempMailAddress2=""
tempBusinessAddress2=""
dupeCtr=0

For j = 1 To dc.Count

For i = 1 To dc.Count
If (tempFirstName1=tempFirstName2) Then
If (tempLastName1=tempLastName2) Then
If (tempOfficePhoneNumber1=tempOfficePhoneNumber2) Then
If(tempCompanyName1=tempCompanyName2) Then
If (tempMailAddress1=tempMailAddress2) Then
If (tempBusinessAddress1=tempBusinessAddress2) Then
dupeCtr=dupeCtr+1
End If
End If
End If
End If
End If
End If

If dupeCtr>1 Then
Call doc2.remove(True)
dupeCtr=1
End If
Set doc2=dc.GetNthDocument(i)
tempFirstName2=doc2.FirstName(0)
tempLastName2=doc2.LastName(0)
tempOfficePhoneNumber2=doc2.OfficePhoneNumber(0)
tempCompanyName2=doc2.CompanyName(0)
tempMailAddress2=doc2.MailAddress(0)
tempBusinessAddress2=doc2.BusinessAddress(0)
Next
dupeCtr=0
Set doc1 = dc.GetNthDocument(j)
tempFirstName1=doc1.firstname(0)
tempLastName1=doc1.LastName(0)
tempOfficePhoneNumber1=doc1.OfficePhoneNumber(0)
tempCompanyName1=doc1.CompanyName(0)
tempMailAddress1=doc1.MailAddress(0)
tempBusinessAddress1=doc1.BusinessAddress(0)
Next
End Sub
This was first published in November 2000

Dig deeper on Domino Resources - Part 5

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:

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