Such a simple task. I got some code from this forum but none addressed creating a new document and copying a RTItem from an existing document. Both documents are based on the same form.
Sub FQJAgent
'*********************************************************************************************
'** This agent will check FQJ - (Frequent Job Requests) and create
'** a new FQJ document if the correct number of days have elapsed
'*********************************************************************************************
Dim Session As New NotesSession
Dim ThisDB As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim view As NotesView
Dim DateTime As New NotesDateTime("")
Dim impdate As New NotesDateTime("")
Dim triggerdate As New NotesDateTime("")
Dim targetdate As New NotesDateTime("")
Dim DateVal As Variant
Dim Item As NotesItem
'*
Dim impdatestring As String
Dim adjustdays As Integer
On Error Resume Next
Set ThisDB = session.CurrentDatabase
Set view = ThisDB.GetView("PMJOBS")
If view Is Nothing Then
End
End If
view.AutoUpdate = False
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
If statement to decide if this document is eligible
to have a new document created !!!!
Set newdoc = ThisDB.CreateDocument
newdoc.DateReceived = TargetDate.LSLocalTime
newdoc.TargetDate = TargetDate.LSLocalTime
newdoc.Form = "MWO"
Call newdoc.save(True,False)
Dim rtitemold As Variant
Dim rtitemnew As Variant
Set rtitemold = doc.GetFirstItem( "Body")
Set rtitemnew = newdoc.GetFirstItem( "Body")
If ( rtitemold.Type = RICHTEXT And rtemnew.Type = RICHTEXT ) Then
Call rtitemnew.AppendRTItem( rtitemold )
End If
newdoc.comments = doc.comments(0)
newdoc.client = doc.client(0)
** etc more fields non-RTItem newdoc.FQJ = “YES”
Call newdoc.save(True,False)
doc.FQJ = "NO"
Call doc.save(True,False)
End If
End If
Set doc = view.GetNextDocument(doc)
Wend
End Sub
Thanks…