Error in Saving and Creating New response document Only for Duplicate Lots

Hi,

            I'm a Notes developer. I get an error message "No document is selected; please select a document to respond to." when saving a response document and creating another response document from it(only for.

I select a document and click “Create Duplicate Lot” view action button in the view. This action button will trigger an Agent “CreateDuplicateLot” which has the following code.

//CreateDuplicateLot agent

Sub Initialize

Dim sess As New NotesSession

Dim ws As New NotesUIworkspace

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection	

Dim SelectedDoc As NotesDocument

Dim DuplicateDoc As NotesDocument	



Set db=sess.CurrentDatabase

Set dc=db.UnprocessedDocuments		

Set SelectedDoc=dc.GetFirstDocument	   '--- >Get the selected document from the view

Set DuplicateDoc=New NotesDocument(db)	  '--- >Create a new document in the database

DuplicateDoc.form="Item"	

Call SelectedDoc.CopyAllItems(DuplicateDoc, True )     '--- >Copy all items from the selected document to the newly created document

Call DuplicateDoc.ComputeWithForm(False,False)

Call ws.EditDocument(True, DuplicateDoc)     '--- >Open the document in the workspace in edit mode	

End Sub

This agent will create a new Item document in the database and inherits the value from the selected Item document in the view and opens it for editing.

In the “Item” form there is a button “Save & Create New” which will save the changes in the opened document and creates another Item document.

“Item” form is of type Response To Response and the code in “Save and Create New” form button is,

//Save and Create New form button

Sub Click(Source As Button)

Dim ws As New notesuiworkspace

Dim uidoc As NotesUIDocument

Set uidoc=ws.CurrentDocument

Call uidoc.Save	

Call ws.ComposeDocument(,,"Item")

	

Dim uidoc1 As NotesUIDocument

Set uidoc1=ws.CurrentDocument	

Call uidoc1.Refresh

End Sub

I get this error only when try to save and create new from a newly created duplicate Lot document but don’t get when just opening a lot document , editing and click “Save and Create New” .

Any help on this issue is greatly appreciated.

Regards,

Murugavel

Subject: Error in Saving and Creating New response document Only for Duplicate Lots

Hi Murugavel,

Try changing your button code to this:

//Save and Create New form button Sub Click(Source As Button)

Dim ws As New notesuiworkspace

Dim uidoc As NotesUIDocument

Dim NewDoc as NotesDocument

Set uidoc=ws.CurrentDocument

Call uidoc.Save

Set NewDoc = uidoc.document.parentdatabase.createdocument()

NewDoc.MakeResponse uidoc.document

NewDoc.Form = “Item”

Call ws.EditDocument(true,NewDoc)

End Sub

This method breaks field value inheritance, so you would have to make sure that you manually copy over any values that you want to appear on the new doc.