Hello,
I am a little new at LS and hoping that someone can help…
I am saving a document on the web using a button consisting of some JS to verify data in required fields, followed by a “document.forms[0].submit()” command.
From there I am using a LS agent called from WebQuerySave. The agent should verify that the document has been saved, then copy it to another database on the same server. If the copy is successful, set a field in the original document to flag it as such. Here is the LS being used in my agent…
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim db2 As Notesdatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim checkdoc As NotesDocument
Dim view2 As NotesView
Dim Trans_DocID As String
Set doc = session.DocumentContext
Set db = session.CurrentDatabase
Set db2 = New NotesDatabase( "" , "fleet-tt.nsf" )
' If current document has been saved, copy it to Fleet_TT.nsf, otherwise save then copy
If doc.IsNewNote Then
Call doc.Save(True, False)
Call doc.CopyToDatabase(db2)
Else
Call doc.CopyToDatabase(db2)
End If
' Verify copy was sucessful, then set flag for remove agent
Set view2 = db2.GetView( "WebTransactions" )
Set checkdoc = view2.GetDocumentByKey( Trans_DocID, True )
If checkdoc.Trans_DocID <> "" Then
doc.Copy_Status = "Copy Successful"
Call doc.Save(True, False)
End If
End Sub
The problem is that while the original document passes verification and saves, the copytodatabase command fails… As a simple test I have added a button to the form that just executes an @Command([FileSave]) to bypass my verification process. Using this method I have found that I must hit the button twice before the copytodatabase command executes, however the original document was saved on the first press.
I’ve searched the forum extensively, but have not found a solution. Can anyone see where I am going astray?? Please help.
Thanks, Steve