Sub Postsave(Source As Notesuidocument) Dim session As NotesSession
Set session = New NotesSession
Dim ThisDb As NotesDatabase
Dim ArchiveDb As NotesDatabase
Dim dc As NotesDocumentCollection
Dim CurrDoc As NotesDocument
Dim TestDoc As NotesDocument
Dim SkillsPoolDoc As NotesDocument
Dim IDList As Variant
Dim invDate As Variant
Dim invNumber As Integer
Dim invStatus As String
Set CurrDoc = Session.DocumentContext
Set ThisDb = Session.CurrentDatabase
ThisDB gets all of the values you would expect but CurrDoc gets nothing, so soon as I try to use CurrDoc I get an error. Any ideas what’s going wrong?
Subject: What’s wrong here? session.documentcontext
How are you calling the agent…?
If you are calling it from the webquerysave… then you can get a handle to the document context…
but ifyou are calling it from a hotspot… the document context is to the agent…
so then you need to pass it a parameter… like ?openagent&docid.
look at the querystring for more or write back… and i’ll send you an example.
Subject: RE: What’s wrong here? session.documentcontext
Betsy, this is in the PostSave event of a form, so is called by the save trigger
Subject: RE: What’s wrong here? session.documentcontext
Are you calling it from the browser…Cause from the browser… you can’t use the post save…
and If you are using the postsave even from the client, you already have a handle to the current document…
PostSave(source as notesuidocument)
If you are calling it from the browser, you need to use webquerysave and call an agent… and in the agent, you can use the set doc = session.documentcontext…
Subject: RE: What’s wrong here? session.documentcontext
It’s callled from the desktop, client, and I want a back-end handle so that I can get field values as their type rather than text. I can’t make out why the document context is not working, that is the question. If you paste that portion of code into a form and step through it in debug, the documentcontext line doesn’t do anything???
Subject: RE: What’s wrong here? session.documentcontext
See what Graham Richards responded…
I don’t think you can use this class from the form events…
why doesn’t source.document work for you…
that will be a backend handl to the document.
Subject: RE: What’s wrong here? session.documentcontext
OK, I imissed Grakam’s post, and looking atthe help it seems that all the examples are agents too. I know I had done this before many years ago, must have used an agent. So now I am bck with your sugggestion of using the uiudoc to access fields which brings me to my next problem… how to get akk the values from a multi value field into an array. ait; such a long times ince I did all this…
Subject: RE: What’s wrong here? session.documentcontext
just dim a variable as a variant
like vmultivalues as variant
vmultivalues = doc.fieldname
you can also just do
forall x in doc.fieldname to loop through all the values
Subject: multi value fields
Thanks Betsie, someone also told me to use the split function which is a newone on me but it works. It automatically takes the multivalue field and creates and populates an array for it. But not all is well with it, myabe you could give me your opinion on this
http://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllThreadedweb/53c20b38f555c989852575a00003138b?OpenDocument
Subject: RE: What’s wrong here? session.documentcontext
As has been suggested by both Betsy and Graham, you just have to make one small change in your code. Change this line:
Set CurrDoc = Session.DocumentContext
to this:
Set CurrDoc = source.document
Everything else stays the same.
Subject: RE: What’s wrong here? session.documentcontext
The help for that method implies it’s to be used by Agents, not forms.
LOTUSSCRIPT/COM/OLE CLASSES
DocumentContext property
Read-only. The in-memory document when an agent starts.
I would suggest you use Source.Document in the PostSave to get to the backend copy of the document that was just saved.
Subject: RE: What’s wrong here? session.documentcontext
Thanks Graham, got it now