Tuesday 25 August 2015

IBM VERSE: Synchronize Recent Contacts from Notes Client to VERSE

Scenario:
Customers appreciate the new User Experience of IBM Verse, but the moment they start using it, the first problem they face is that while typing name, recent contacts are not available, which are there in Notes Client. So, customers were forced to either search customer emails or copy from Notes Client.

To avoid the same, I created a script to copy the Recent Contacts to My Contacts and Sync it to Server.

Steps are as follows: :

1.Create a Notes button using following code to Migrate Recent Contacts in Notes Client to My Contacts.

Sub Click(Source As Button)
    Dim s As New NotesSession
    Dim vw As NotesView
    Dim doc As NotesDocument
    Dim db As NotesDatabase
    Dim doc2 As NotesDocument
    On Err Goto ErrHandler
    Dim total As Integer, cnt As Integer
    msg = "Please ensure that you don't run this code multiple times, else it will create duplicates in your Addressbook. " + Chr(10) & _
    "Are you sure to run this code ?"
    If Messagebox(msg, 36, "Are you sure ? ") = 7  Then
        Msgbox "The action has been cancelled", 64, "Cancelled"
        Exit Sub
    End If
    Set db = s.GetDatabase("", "names.nsf")
    Set vw = db.GetView("RecentCollaborators")
    total = vw.AllEntries.Count
    cnt = 0
    Set doc = vw.GetFirstDocument
    While Not doc Is Nothing
        cnt = cnt + 1
        Print "Processing " & cnt & " / " & total & " document"
        Set doc2 = vw.GetNextDocument(doc)
        RCtype = doc.GetItemValue("type")
        If Lcase(RCtype(0)) = "group" Then
            'Skip the doc
        Else
            'Move to My Contacts
            Call RCReplace(doc, db)
        End If
NextDoc:
        Set doc = doc2
    Wend
    Messagebox "Migration process has completed.", 64, "Complete"
    Exit Sub
ErrHandler:
    Goto NextDoc
End Sub

Sub RCReplace(RCDoc As notesdocument, db As NotesDatabase)   
    On Error Resume Next
    Call RCDoc.replaceitemvalue("Form", "Person")  'DNT
    If Lcase(rcDoc.getitemvalue("Type")(0)) <> Lcase("PeRsOn") Then
        Call RCDoc.replaceitemvalue("Type", "Person")   'DNT
        'this code is in place for Mail-In Database records, with only  hierarchical name in Fullname item
        RCFN = rcdoc.getitemvalue("Fullname")
        If Ubound(RCFN) = 0 Then
            Dim FNname As New notesname(RCFN(0))
            CanonFN = FNname.canonical
            If CanonFN <> "" Then
                Redim NewFN(1)               
            End If
            NewFN(0) = FNname.canonical
            NewFN(1) = FNname.common
            Call RCdoc.replaceitemvalue("Fullname", NewFN)
        End If
        ' /end Mail-In Db specific code
    End If   
    Call RCdoc.replaceitemvalue("$AutoCreatedList", "")
    Call RCdoc.replaceitemvalue("$DPABState", "")
    Call RCdoc.replaceitemvalue("$DPAB_State", "")   
    Call RCDoc.save(False,False)
    Set newContact = RCdoc.CopyToDatabase( db )
    Call RCDoc.remove(True)
End Sub

Note: Click "Yes" if any prompt comes up for Trusting Code.

2. Goto Notes Client --> File Menu --> Preferences.

3. Open Contacts section and ensure "Enable Synchronize Contacts" option is enabled.

clip_image001

4. Goto Replication and Sync Tab and ensure that "Synchronize Contacts Replication is Enabled.

clip_image002

5. Once Synced, All the Recent Contacts will be available in IBM Verse as well !

For more details, refer to IBM Wiki.

No comments:

Post a Comment