Set doc=NSession.DocumentContext and object variable not set

Hello all:I have an agent that runs on server through a button in a form when I reach this line of code in my agent

Set doc=NSession.DocumentContext

I get an error in log “Object variable not set”

thanks

Dalia

Subject: Set doc=NSession.DocumentContext and object variable not set

hisee in Designer Help, searching for “DocumentContext”:

This agent displays the Subject item of the current document when run from a view in the Notes client.

Sub Initialize

Dim session As NotesSession

Set session = New NotesSession

Dim doc As NotesDocument

Set doc = session.DocumentContext

Messagebox doc.Subject(0), “Subject”

End Sub

Subject: RE: Set doc=NSession.DocumentContext and object variable not set

Red herring. Dalia has posted elsewhere about this ( - please keep stuff in one thread!), and in this post neglects to mention that the agent in question is invoked programmatically by another agent (the other agent is the one in the button)-- it therefore has no idea of DocumentContext, as programmatically invoked code is exclusively “back-end”.

Personally, I would just move the requisite code into one or more script library routines. When the button is pressed, it can pass along reference to the relevant NotesDocument object to the other routine(s).