How to encrypt a NotesUIDocument on close

We have a need to force encryption of fields in a NotesUIDocument on close, whether or not any changes have been made to the document.

The scenerio is:

Before the document is opened, if we look at the document properties from the view, the encrypted fields in the document are in fact encrypted and not visible from document properties. However, once the document is opened, and you right click to look at document properties from within the document, the encrypted fields are visable in clear text. When you close or close w/o save and again look at document properties from the view, the encrypted fields are still visible in clear text. A ToolsRefreshSelectedDocs will again encrypt the fields, but that has to be done manually. There has to be a way of doing this programmatically.

I’ve tried source.Refresh, doc.Encrypt, but neither seems to work. We always get the Notes Error: “Cannot encrypt NotesDocument when instantiated by a NotesUIDocument.”.

Is there a way to force the NotesUIDocument to be encrypted on close?

Subject: Could this be a caching issue ?

If you open an encrypted document in the client, and then close it without saving, then the document in the database has not changed. (Be sure that there’s nothing funny going on in your form events that may be saving the document transparently…)

If you can see the fields in the clear via document properties, I would suspect that the document is cached by the client, and it’s that version document you are seeing the properties for, rather than the one in the database.

To validate that, have a second person look at the document properties from the view - you’ll probably find it’s still encrypted.

If not, something else is going on, and I’d suggest using the debugger to trace any script that’s being executed.