Hi all,
Im doing an agent to copy a current document into same database. (web application). I need to copy the form and its related response form. But, what I get is, the main form is success copied but the response form only can copied one document. I have no idea to solve. Anyone can give me solutions?
Below is my agent:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As notesdocument
Dim view As NotesView
Dim vdoc As NotesDocument
Dim sview As NotesView
Dim sdoc As NotesDocument
Dim child As notesview
Dim childdoc As NotesDocument
Dim cdoc As notesdocument
Dim procStatusItem As NotesItem
Dim nobj As NotesName
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Set nobj = New NotesName(session.EffectiveUserName)
doc.copyFlag = “Yes”
Set procStatusItem = doc.GetFirstItem(“SCProcessStatus”)
remarks = “This Claim Form copied to another new Claim Form” & " by " & nobj.Common & " on " & Today() & " " & Time()
Call procStatusItem.AppendToTextList( remarks )
Call doc.Save(True,True)
Set view = db.GetView(“(AllHeaderView2)”)
Set vdoc = view.GetDocumentByKey(doc.SCEmpID(0)+doc.SCClaimNo(0),True)
Call vdoc.CopyToDatabase(db)
vdoc.SCStatus = “New”
vdoc.CurrLevelApp = doc.TotalApp(0)
vdoc.SubmitFlag = “”
vdoc.SCStatusDisp = “New”
vdoc.ApprovalStatus = “”
vdoc.Approver = “”
vdoc.SCAdjustMileageFlag = “”
vdoc.prevMileage = “”
vdoc.copyFlag = “”
Set seqview = db.GetView(“(SerialNo)”)
Set seqdoc = seqview.GetDocumentByKey(doc.SCEmpID(0),True)
If Not (seqdoc Is Nothing) Then
seqdoc.ClaimSerialNo = seqdoc.ClaimSerialNo(0) + 1
claimno = seqdoc.ClaimSerialNo(0) + 1
End If
Call seqdoc.Save(True, True)
vdoc.SCClaimNo = Year(Today()) & “-” & Format(seqdoc.ClaimSerialNo(0),“0000”)
vdoc.SerialNo = Val(seqdoc.ClaimSerialNo(0)) + 1
vdoc.SCProcessStatus = "Claim Copied from Claim No. " & doc.SCClaimNo(0) & " by " & nobj.Common & " on " & Today() & " " & Time()
vdoc.DateApplied = Today() & " " & Time()
vdoc.LastUpdateDateTime = Today() & " " & Time()
vdoc.LastUpdateName = session.EffectiveUserName
Call vdoc.Save(True,True)
Set child = db.getview(“(AllChildRejectedView)”)
Set childdoc = child.GetFirstDocument()
While Not (childdoc Is Nothing)
If childdoc.SCDEmpID(0) = doc.SCEmpID(0) Then
If childdoc.SCDClaimNo(0) = doc.SCClaimNo(0) Then
Call childdoc.CopyToDatabase(db)
childdoc.Approver = “”
childdoc.SCDStatusDisp = “New”
childdoc.SCDStatusADJ = “”
childdoc.prevAdj = “”
childdoc.SCDClaimNo = Year(Today()) & “-” & Format(seqdoc.ClaimSerialNo(0),“0000”)
childdoc.SCDStatus = “New”
childdoc.SCDAdjustment = “”
Call childdoc.Save(True,True)
End If
End If
Set childdoc = child.GetNextDocument(childdoc)
Wend
End Sub
Thank You.