The code below works to create a new document in the personal address book and copy fields from my butchered addressbook. (aka rolodex). I appreciate the help I received on this last night.
I have a new problem in that I need to refresh the new document after it’s saved so that the Blackberry software recognizes it. I recognize that I need to rewrite this to use uidoc.refresh but I cannot get the syntax right.
I think I may need to start over.
Before I do that does anyone have any sugestions?
I recognize that the GetNthDocument(n) is not the most efficient and I’ll change it before this goes into the production environment.
Thanks for your time.
Dim s As NotesSession
Dim sourcedb As NotesDatabase
Dim destdb As NotesDatabase
Dim sourcenote As NotesDocument
Dim sourceview As NotesView
Dim destnote As NotesDocument
Dim destview As NotesView
Dim documents As NotesDocumentCollection
Dim Item as Notesitem
Sub Initialize
Set s = New NotesSession
Set sourcedb = s.CurrentDatabase
Set destdb = New NotesDatabase(“”, “names.nsf”)
Set destview = destdb.GetView(“($Users)”)
Set sourceview = sourcedb.GetView(“($Users)”)
Set documents = sourcedb.UnprocessedDocuments
If documents.Count = 0 Then Exit Sub
DocsCopied = 0
For n = 1 To documents.Count
Set sourcenote = documents.GetNthDocument(n)
ProcessDocument
If StopProcessing Then Exit For
Next
End Sub
Sub ProcessDocument
Set destnote=destdb.createdocument
Set item = sourcenote.GetFirstItem(“Firstname”)
Call item.copyitemtodocument(destnote, “Firstname”)
Set item = sourcenote.GetFirstItem(“Lastname”)
Call item.copyitemtodocument(destnote, “Lastname”)
Set item = sourcenote.GetFirstItem(“StreetAddress_Pr_Bu”)
Call item.copyitemtodocument(destnote, “OfficeStreetAddress”)
destnote.Type=“Person”
destnote.form=“Person”
destnote.save True,False
End Sub