Search code examples
lotusscript

Finding duplicate Contacts in Recent Contacts View


I need to write code for finding duplicate entries in recent contact view within same internal domain. I'm not going to touch external internet contacts. Is there any special Property or method to do it (in lotus script?) comparing all the view entries with server nab is the good idea? can anyone suggest me best way to do this?


Solution

  • Not sure if I fully get what you need, but here is what I suggest

    I would suggest to write small bunch of code that walk via view (Recent Contacts) and create a list and put there only unique pair of key/doc and store in another place all duplicates.

    you can create an agent with such code (please notice, I may use wrong key, so just define what field for you is a unique key) i.e.

    Dim session As New NotesSession
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim uniquedocs List As Variant
    Dim duplicates As string
    Dim key As String
    
    Set view = session.Currentdatabase.Getview("(Recent Contacts)")
    Set doc = view.Getfirstdocument()
    While Not doc Is Nothing
        ' this is the unique key, please change it if you need
        key = doc.Getitemvalue("MailDomain")(0)
    
        If key <> "" Then
            If Not IsElement(uniquedocs(key)) Then
                Set uniquedocs(key) = doc
            Else
                If duplicates <> "" Then duplicates = duplicates & " | "
                duplicates = duplicates & key
            End If
        End If
    
        Set doc = view.Getnextdocument(doc)
    Wend
    
    MsgBox duplicates
    

    duplicates - is a string with all mail domains that have at least 2 contacts in view (Recent Contacts)