I have a NotesDocument, which is the DocumentContext (web). In a WebQuerySave, I want to convert that NotesDocument to a NotesDocumentCollection.
Here’s my code (after looking around on this forum) :
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Set doc = session.DocumentContext
Dim dc As NotesDocumentCollection
'For unknown reason, before adding a document, the DC must be initialized to something
Dim view As NotesView
Set view = db.GetView(“va_all”)
Set dc = view.GetAllDocumentsByKey(“%dummy$”, True)
Call dc.AddDocument(doc)
However, it always generate an error on the “AddDocument” line (“Invalid Note ID”).
I suspect this might happen because this code runs on the WebQuerySave event and that my document has never been saved yet.
I want to convert the web context document to a NotesDocumentCollection because I have to call an existing function that requires this type as the only parameter.
Is there a way to do this? (convert a NotesDocument to a NotesDocumentCollection containing only one doc)
Subject: How to transfer a NotesDocument into a NotesDocumentCollection?
I think you are right about the cause. I have had to do this kind of thing before, but not with an unsaved document. Note that the documentation states that you should NOT explictly save a context document in a Web Query Save agent…
If you are really stuck with this interface, you might want to do the following (its horrible, I know)…
Clone the context document.
Save the copy.
Add it to your empty document collection and call your function.
Copy the results from your clone back to the original context document.
Let the Web Query Save agent save your context document.
Subject: RE: How to transfer a NotesDocument into a NotesDocumentCollection?
If I try this from the web with agent document selection set to “None”, I don’t seem to get a collection. The documentation doesn’t say that it doesn’t work on the web, but I have never been able to use it. Am I doing something wrong?
The code below results in “Nope” and “Got Context” when run from a new web document (either by URL or WebQuerySave).