WebQuerySave and documentContext

I would like to say I’m pretty new with Domino/Notes.

I have a form, to be used on the web. I use an agent in WebQueryOpen that gets information from the URL and stores it in Fields on the form. This seems to work fine. To test, I let the agent send me an e-mail with the values of the fields. And they are all correct. Here’s the code I used (fGetParameterValue is a function I use and this works fine):

DocumentID = fGetParameterValue (QueryString, “DocID”)

Source = fGetParameterValue (QueryString, “SRC”)

docCurrent.Reference = Source

docCurrent.DocumentID = DocumentID

Now, I want to use an agent in WebQuerySave. In that agent I want to retrieve the values from the fields Reference and DocumentID.

I tried the following in my agent:

Dim session As New NotesSession

Dim dbCurrent As NotesDatabase

Dim docCurrent As NotesDocument

Dim DocumentID As String

Dim Source As String

Set dbCurrent = session.CurrentDatabase

Set docMail = New NotesDocument (dbCurrent)

Set docCurrent = session.documentContext

DocumentID = docCurrent.DocumentID(0)

Source = docCurrent.Reference(0)

But DocumentID and Source remain blank (or null, not sure).

My agent runs. I also let the agent send me an email and from this mail I can tell the values are blank … What am I missing?

I’m calling the agent from WebQuerySave. I have a button on the form that triggers this, so that should be fine, no?

Subject: Are the fields on the form?

I think you’re really close but I have some questions.

  1. You say that you trigger the WebQuerySave through a button… I assume the button does a form.submit or a @command([filesave]) + @Command([fileclosewindow]).

  2. Do you have the fields Reference and DocumentID somewhere on the form (they can even be hidden)? If the fields are not in the Form properties… WebQuerySave will not pick them up.

Subject: Yes, they are

Hi,

Yes, the fields are in the form. And I can retrieve the values from them as well in my agent in WebQueryOpen.

The button has following JS command: document.forms[0].submit() ;

Thanks,

Pascal

Subject: Straight from the notes help…

Note: WebQueryOpen agents run when the user opens a form or document, but do not run when the user saves a document. This means that computed fields set by a WebQueryOpen agent are not saved when the user submits a document. To make sure computed fields are saved, you can either recalculate them in the WebQuerySave agent or set the form property “Generate HTML for all fields.”

Subject: Another thing

Hi,

I found out something else. There’s also a third field with the E-Mailadress. This field was set to Computed. Same problem. But when I change the field to Editable, it works fine. In my agant in WebQuerySave I then can read the value from this field without any problem.

But I don’t want these fields to be editable. I get the values from the URL. In the URL I pass on the documentid. In the agent in WebOpenQuery I then lookup this document and get the e-mailaddress and put it in the field. Same for the Reference address. So these fields don’t need to be edited.

Subject: WebQuerySave and documentContext

First of all, your problem is not with reading the fields, but with setting them, and keeping the values. Values set from WebQueryOpen will not get reposted back to the WebQuerySave, and will disappear.

Unless:

Create an html field by writing: and mark it as passthru-html.

As long as the name of the hidden field is the same as the name of your computed field, the value will be posted back to the server for you.

You could also populate your computed fields with an @UrlQueryString( parameterName ) instead of doing it in WebQueryOpen, that should avoid the problem…