Hello,
I am seeing “Requires a valid ADT argument” on this line of code:
Call newdoc.CopyItem( item, “RegMark” )
Does anyone know how I can fix this?
I will display all the code below, but first, this is what I’m trying to do.
I have a document which can list between 1 and 5 car registrations depending on how many cars you have. For each car registration, when this document is approved, it should create another document for each car, with the registration field already filled in.
This code is in an agent. Here is the code:
Initialize Section:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim view As NotesView
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim user As String
Dim strFieldName As String
Set db=session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc=uidoc.Document
uidoc.Reload
uidoc.Refresh
If ( Trim(doc.RegMark(0)) <> "") Then
Call CreateNew (db, doc, doc.RegMark(0))
End If
For a = 1 To 4
strFieldName = "RegMark_" + a
If ( Trim(doc.GetItemValue( strFieldName)(0) ) <> "") Then
Call CreateNew (db, doc, strFieldName)
End If
Next
End Sub
CreateNew SubRoutine
Sub CreateNew (db As NotesDatabase, doc As NotesDocument, regMarkFieldName As String)
Dim newdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim AutoCheckDate As New NotesDateTime("")
Dim AutoNextCheckDate As New NotesDateTime("")
Dim item As NotesItem
'create new document
Set newdoc=New NotesDocument(db)
Set rtitem =New NotesRichTextItem(newdoc,"Body")
Set AutoCheckDate = New NotesDateTime("Today")
Set AutoNextCheckDate = New NotesDateTime("Today")
Call AutoCheckDate.AdjustMonth(-1)
Call doc.Save(False,False)
newdoc.Form = "Vehicle Check Report"
newdoc.Name = doc.Name
newdoc.Tel = doc.Tel
newdoc.Dep = doc.Dep
newdoc.JobTitle = doc.JobTitle
'newdoc.RegMark = doc.GetItemValue( regMarkFieldName )
Call doc.Save(False,False)
Set item =doc.GetFirstItem (regMarkFieldName)
Call newdoc.CopyItem( item, "RegMark" )
newdoc.CompanyHireCar = doc.CompanyHireCar
newdoc.OnshoreOffshore = doc.OnshoreOffshore
newdoc.Status = "Current"
newdoc.RetToggle = "Yes"
Call newdoc.ReplaceItemValue("VehicleCheckDate", AutoCheckDate)
Call newdoc.ReplaceItemValue("NextVehicleCheckDate", AutoNextCheckDate)
Call newdoc.Save(True, True)
'create new mail
newdoc.Form="Memo"
newdoc.Subject="Crawley Business Drivers DB - Vehicle Check Form enclosed for " & doc.FullName(0)
Call rtitem.AppendText("Please find below the Vehicle Check Form for you to complete on a regular basis.")
Call rtitem.AddNewLine(1)
Call rtitem.AppendText("Please contact Facilities if you require further information.")
Call rtitem.AddNewLine(2)
Call rtitem.AppendText("Please follow the link to view the document ->> ")
Call rtitem.AppendDocLink(newdoc,db.Title)
Call rtitem.AddNewLine(2)
Call rtitem.AppendText("Thank you...")
Call rtitem.AddNewLine(2)
flag=newdoc.ComputeWithForm(False,False)
Call newdoc.Send (False, doc.GetItemValue("FullName" ))
End Sub
I’d really appreciate any help with this as I’m completely stuck.
Thanks in advance,
Hayley.