REPOST - can't get handle on current document

My code is in an action button on the form.

So I am trying to get a handle on the current saved document but am receiving an error message when I use ws.currentdocument OR session.documentcontext.

This script used to work pre 8.5.

Why if I have the saved doc open can I not get a handle using ws.currentdocument. I set a new ws. Not even session.documentcontext.

how would I check uidoc.editmode then? weirdness.

Please help. THANKS!!

Subject: SOLVED

It only happens for me in DEBUG mode - go figure!

Subject: I am getting the same problem - CURRENTDOCUMENT property is empty

Dim workspace As New NotesUIWorkspaceDim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

dim doc as NotesDocument

Set doc = uidoc.Document

UIDOC is nothing - even with existing document…ANY IDEAS???

Subject: session.documentcontext

Has anyone resolved this? I’m seeing the same thing on a server-based agent. It works fine on the workstation but does not get the document when running on the server. This used to work. What the heck is going on? This is about to break a bunch of stuff for an upgrade I was going to do.

Subject: need help understanding problem

session.documentcontext is not failing in 8.5 in any obvious way, for myself.

You stated “…but does not get the document when running on the server.”

How is it running on the server (agent.runonserver, webagent, mail event, etc) ? What was the nature of the document that was being returned priorto 8.5?

Any context, detail, or examples would be appreciated in order to see the problem.

Subject: need help understanding problem

The first response in this thread has this sample code:

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

dim doc as NotesDocument

Set doc = uidoc.Document

Putting that code in a button on a form is seen working in 8.5.

If you’re still having trouble with this could you provide more detail, or, better, a sample db, or instructions to reproduce starting from a new database ?

session.documentcontext was mentioned as well. That method is meaningful in only in an agent under certain circumstances of course, so it’s not clear how/if this problem is related to the form button. Again, any help to see the problem would be appreciated.