Have a database that has a main document with two set of address fields in it…
address1, address2, city, state, zip…
and
paddress1, paddress2, pcity, pstate, pzip …
I need to move each address block to individually to a response document. .so that I wind up with 1 main document, and two address documents that are responses to the main doc.
Have 4,300 records, so obviously need to do this in an agent.
I realize it will probably have to be done in Lotussscript… but am novice at that, and not sure how to approach this problem.
' The Patented Regenold Response Creator
On Error Goto ErrHandle
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim agentLog As New NotesLog("Regenold Response Creator")
Call agentLog.OpenFileLog( "c:\log.txt" )
Dim view As NotesView
Set view = db.GetView( "(Some Lookup View)" )
Call view.Refresh()
Dim doc As NotesDocument
Set doc = view.GetFirstDocument
If doc Is Nothing Then
Goto Done
End If
While Not doc Is Nothing
Dim item As NotesItem
Dim errorFlag As Boolean
errorFlag = False
' Create Response A
Dim docA As New NotesDocument( db )
Call docA.MakeResponse( doc )
docA.Form = "SomeForm"
Set item = doc.GetFirstItem( "address1" )
Call docA.CopyItem( item, "address1" )
Set item = doc.GetFirstItem( "address2" )
Call docA.CopyItem( item, "address2" )
Set item = doc.GetFirstItem( "city" )
Call docA.CopyItem( item, "city" )
Set item = doc.GetFirstItem( "state" )
Call docA.CopyItem( item, "state" )
Set item = doc.GetFirstItem( "zip" )
Call docA.CopyItem( item, "zip" )
If docA.ComputeWithForm( True, False ) Then
Call docA.Save( True, False )
Else
Error 101, "Response docA for doc " + doc.Title(0) + " did not save."
errorFlag = True
End If
' Create Response B
Dim docB As New NotesDocument( db )
Call docB.MakeResponse( doc )
docB.Form = "SomeForm"
Set item = doc.GetFirstItem( "paddress1" )
Call docB.CopyItem( item, "paddress1" )
Set item = doc.GetFirstItem( "paddress2" )
Call docB.CopyItem( item, "paddress2" )
Set item = doc.GetFirstItem( "pcity" )
Call docB.CopyItem( item, "pcity" )
Set item = doc.GetFirstItem( "pstate" )
Call docB.CopyItem( item, "pstate" )
Set item = doc.GetFirstItem( "pzip" )
Call docB.CopyItem( item, "pzip" )
If docB.ComputeWithForm( True, False ) Then
Call docB.Save( True, False )
Else
Error 102, "Response docB for doc " + doc.Title(0) + " did not save."
errorFlag = True
End If
' Remove original values
If errorFlag <> True Then
Call doc.RemoveItem("address1")
Call doc.RemoveItem("address2")
Call doc.RemoveItem("city")
Call doc.RemoveItem("state")
Call doc.RemoveItem("zip")
Call doc.RemoveItem("paddress1")
Call doc.RemoveItem("paddress2")
Call doc.RemoveItem("pcity")
Call doc.RemoveItem("pstate")
Call doc.RemoveItem("pzip")
If doc.ComputeWithForm( True, False ) Then
Call doc.Save( True, False )
Call agentLog.LogAction("Success: " & doc.Title(0))
Else
Error 103, "Doc " + doc.Title(0) + " did not save."
End If
errorFlag = False
End If
NextDoc:
Set doc = view.GetNextDocument(doc)
Wend
Goto Done