Get this error, have not been able to track it down — Function requires a valid ADT arguement…
Running this script to create 2 response docs from data in the main doc… i get the error above… Have not been able to pin it down.
Any help appreciated for sure!!!
The view selection only has the form Contact listed… was thinking it might need the form Addresses listed too?
Sub Initialize
On Error Goto ErrHandle
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim agentLog As New NotesLog("Response Creator")
Call agentLog.OpenFileLog( "d:\log.txt" )
Dim view As NotesView
Set view = db.GetView( "Contacts - by Person" )
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 = "Addresses"
Set item = doc.GetFirstItem( "OfficeStreetAddress" )
Call docA.CopyItem( item, "StreetAddress" )
Set item = doc.GetFirstItem( "OfficeCity" )
Call docA.CopyItem( item, "City" )
Set item = doc.GetFirstItem( "OfficeState" )
Call docA.CopyItem( item, "State" )
Set item = doc.GetFirstItem( "OfficeZip" )
Call docA.CopyItem( item, "Zip" )
Set item = doc.GetFirstItem( "OfficeStAbbr" )
Call docA.CopyItem( item, "StateAbbreviation" )
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 = "Addresses"
Set item = doc.GetFirstItem( "StreetAddress" )
Call docB.CopyItem( item, "StreetAddress" )
Set item = doc.GetFirstItem( "City" )
Call docB.CopyItem( item, "City" )
Set item = doc.GetFirstItem( "State" )
Call docB.CopyItem( item, "State" )
Set item = doc.GetFirstItem( "Zip" )
Call docB.CopyItem( item, "Zip" )
Set item = doc.GetFirstItem( "StateAbbreviation" )
Call docA.CopyItem( item, "StateAbbreviation" )
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("OfficeStreetAddress")
Call doc.RemoveItem("OfficeCity")
Call doc.RemoveItem("OfficeState")
Call doc.RemoveItem("OfficeZip")
Call doc.RemoveItem("OffStAbbr")
Call doc.RemoveItem("StreetAddress")
Call doc.RemoveItem("City")
Call doc.RemoveItem("State")
Call doc.RemoveItem("Zip")
Call doc.RemoveItem("ZipAbbreviation")
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
ErrHandle:
Print "Error" & Str(Err) & ": " & Error$
Call agentLog.LogAction("Error" & Str(Err) & ": " & Error$)
Resume NextDoc
Bail:
Call agentLog.Close
Print ""
Done:
End Sub