I’m having fun tonight!
I have a DB created using the 4.5 NAB as a template. It’s been tweaked over the years with many new fields and views added. It’s used as a rolodex of people outside the company and is integrated into our emarketing, event invitation, and targeted mailing systems.
So what’s my problem? People now want to be able to copy entries from this “rolodex” to their 6.5 personal address books.
If I use copytodatabase(destdb) like in the CopyToPAB agent I run into three problems:
a. the form name in the rolodex is no longer “Person”
b. Some of the field names (mostly business address fields) have changed.
c. I’m copying a bunch of unnecessary fields.
If I use CopyAllItems I can eliminate problem “a” above but still have “b” and “c”.
If I use CopyItem I can eliminate all three problems but it’s going to be long and tedious to set up.
Here’s where I’m at. Does it look like the right approach?
It would be great to get some feedback. Lotus script is not something I’m good at. I just cut, paste and pray.
Thanks
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.form="Person"
destnote.save True,False
End Sub