Removing the document when closing it

Hi

I have an application in which the user can preview a document and use a print button to print the document. When the user then close the document I want to delete that document from the system. I use the following lotusscript code in the queryclose event of the form:

Dim doc As NotesDocument

Dim s As New NotesSession

Set doc =Source.Document

Call doc.Remove(True)

But when I test this and close the document I receive the message “Cannot remove NotesDocument when instantiated by NotesUIDocument”

How can I remove the document from the application when the user closes the document ?

Regards

Subject: Removing the document when closing it

May be try moving the deletion to the PostClose event and try

HTH

Keshava

Subject: Removing the document when closing it

When you preview the document do you create a new document and save it then?

Maybe you just need to create a new form for printing, and simply switch to that form for previewing and subsequently printing. Make sure there’s a SaveOptions field on it with value “0”. It will never be saved.

The problem you’re having is a common one, there’s plenty of info about it on the forum.

Dan

Subject: Removing the document when closing it

One of the options is to just mark the document for deletion (so it does not show in the normal views), then actually delete it with a scheduled “clean up” agent.

HTH,

Simeon

Subject: Removing the document when closing it

The error message hints at a solution: Remove the back end document - not the front end. In QueryClose:

Dim s as New NotesSession

Dim doc as notesdocument

unid$ = source.document.UniversalID

set doc = s.currentdatabase.GetDocumentByUNID( unid$ )

call doc.Remove(True)

You can also do this in fewer lines:

dim doc as notesdocument

set doc = source.document.parentdatabase.getdocumentbyunid( source.document.universalid )

call doc.remove( true )

VH