Nice trick...creating responses before WebQuerySave saves the parent document

Hi there,

A bit of programming magic that I found in the R4 forum but not easily found. I had a problem where I needed to set a number of response documents to a newly-created parent document on the web. WEBQUERYSAVE is the agent I could use, but because it runs before the document is saved, I couldn’t use the LS MakeResponse method. Instead I was able to set the $REF field programmatically by setting ~$REF. Trying to set $REF created a syntax error but the tilde (~) in front of the field name did the trick…when I looked at the main document all the nice little response documents I created BEFORE the parent was saved nicely showed up in an embedded view. Tested in R6.5 and R5.0.12. Just thought I’d add this to our collective knowledgebase.

…Neil

Subject: Nice trick…creating responses before WebQuerySave saves the parent document

From my understanding and experience:

When the agent which you call with the WebQuerySave event is initialized no document is saved until then. This is also the purpose of this event. This way you still can perform some needed actions.

So, what you can do now is just save the new document first and then set the response documents. You can access the new document through the NotesSession

Dim ses As New NotesSession

Dim newDoc = ses.DocumentContext '*** Received doc from browser

Call newDoc.Save(True, False)

Now you can set your response documents

This is just another idea.

Regards

Subject: I read that saving the doc isn’t a good idea in webquerysave…

But my own solution is causing some inconsistent behaviour with the $Ref field. I’ve worked around it but I think I’ll abandon the response hierarchy for later versions.

Thanks…Neil

Subject: Nice trick…be warned

If you try this, you should first read up on the subject of doing a Save() of a document during the document’s own WebQuerySave(). In short, the Help says not to do it, but YMMV.