Dialog box and Lotuscript button

Hi ,I use a LS agent to pop up a dialog box. I have custom action button on the dialog box( Save and Close).

I want to add a Copy button on the dialog box to create a new document .

I using the following code for copy button.I am getting the error " Un able to find document window " .I feel that

Set uidoc = workspace.CurrentDocument does not work with dialog box.

Does any one know a work around for this/ method to achieve this.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim newUIDoc As NotesUIDocument

Dim newDoc As NotesDocument

Set uidoc = workspace.CurrentDocument

Call uidoc.Save  

'Set doc = uidoc.Document



Call workspace.ComposeDocument("", "", "frmCoredocument")

Call doc.Save(True, False)

Call uidoc.Close

Set newUIDoc = workspace.CurrentDocument

Set newDoc = newUIDoc.Document

 'Copy fields to new doc

newDoc.txtcustname= doc.txtcustname

newDoc.FacilityName= doc.FacilityName

newDoc.accountoff = doc.accountoff

newDoc.DispDocReviewStatus= doc.DispDocReviewStatus



Call newUIDoc.Reload

End Sub

Thanks

Sushant

Subject: RE: Dialog box and Lotuscript button

You can’t compose a new document from within a dialogbox because the dialog is modal. Your code that opened the dialog will have to compose the document, based on information returned by the dialog.

Subject: RE: Dialog box and Lotuscript button

Thanks Andre for the response!.I am looking for a work around . In which user does not have to close the dialog box and clicks on copy button to copy the current contents and create a new doc .

Thanks

Sushant

Subject: RE: Dialog box and Lotuscript button

But before putting too much energy into searching for a workaround, make sure you fully get the concept of an application modal dialog.

Subject: RE: Dialog box and Lotuscript button

Does the new document have to open on screen, or could you just create it in the back end?

If it has to open, you could have the dialog close, assigning a field to let the calling code know that you want to open a new document, have that code open the new document, then reopen the dialog. But because the dialog is modal, you can’t edit the document you opened until the dialog is closed – just look at it.

Perhaps instead of a dialogbox, you should think about opening a frameset that contains the “dialog” in one frame and composes documents in another frame?