Refreshing a Document on the Web

This is a follow-up to a previous post.

I have a Notes database with a web front end. I found that if a form action uses an ‘Alert’ to display a message, a white page is displayed afterwards instead of the open document. (The ‘Alert’ causes $$Return to not function properly.)

As was described in a response to my previous post, the following enables a message to be displayed without impacting $$Return:

  1. Add a computed field (‘MessageField’) to the form. Surround this with a tagset. Mark the field and tagset as ‘Pass through HTML’.

  2. Assign a message to MessageField in the WQS agent as follows: doc.MessageField = “alert(‘This is a test’);”

This results in the message ‘This is is Test’ being displayed when the WQS runs.

This works ideally except that it’s necessary for messages to be displayed at a number of points in the processing logic, including an error handling routine. Accordingly, I’ve made the additional changes:

3.) Added another computed field named ‘MessageFieldTemp’ to the form. (This does not have a tagset and is not marked as ‘Pass through HTML’.)

4.) Assign a message to MessageFieldTemp in the error handling routine (and other routines that display messages).

5.) Modified the code in the WQS agent as follows:

Dim arg as String

If doc.MessageFieldTemp(0) = “” Then

doc.MessageField = “”

Else

arg = doc.MessageFieldTemp(0)

doc.MessageField = “alert('” + arg + “');”

End If

This addresses the need to generate messages from various points in the logic. However, both MessageField and MessageFieldTemp need to be reset to null. Otherwise, the last message will be displayed again the next time the WQS or WQO executes. I’ve tried each of the following:

A.) Added the following code to the end of the WQS agent:

doc.MessageField = “”

doc.MessageFieldTemp = “”

B.) Added another agent to end of the form action to null out MessageField and MessageFieldTemp. The form action is as follows:

@Command([ToolsRunMacro]; “(ProcessingAgent)”);

@Command([FileSave]);

@Command([ToolsRunMacro]; “(NullMessageFieldsAgent)”)

NullMessageFieldsAgent includes the following:

doc.MessageField = “”

doc.MessageFieldTemp = “”

Call doc.save(True, True)

C.) Modified the form action as follows:

@Command([ToolsRunMacro]; “(WebStringSubmit)”);

@Command([FileSave]);

@SetField(“MessageField”;“”);

@SetField(“MessageFieldTemp”;“”);

@Command([FileSave]);

The changes made in A,B and C all result in no message being displayed.

In summary, the changes made in items 1 - 5 above result in a message being displayed from various points in the processing logic with the document being properly displayed afterwards by $$Return.

There’s a remaining problem in that the two added fields (MessageField and MessageFieldTemp) need to be reset to null after a message is displayed and it’s not apparent how this might be done. I’ve tried the measures described in items A, B, and C, but each results in no message being displayed.

I’d appreciate any suggestions as to how MessageField and MessageFieldTemp might be set to null.

Thanks.

Subject: Refreshing a Document on the Web

If you only want to set these two fields to null when the document is being saved change their computed values to:

@If(@IsDocBeingSaved ; “” ; YourFieldName )

The WQO agent should still set their values properly depending on the code it generates.

Subject: RE: Refreshing a Document on the Web

I provided too many details. Here’s a simplified version:

A form has a field that displays a message when the WebQuerySave runs. The field is computed with a tagset and uses 'Pass through HTML". It’s assigned a value as follows in a WebQuerySave agent:

doc.MessageField = “alert(‘This is a test’);”

Because the field is defined in this manner, the message ‘This is a test’ is displayed when the WebQuerySave runs.

Here’s the problem - after the message is displayed, the field needs to be set to null. Otherwise, the message will be displayed again the next time the document is opened and the WebQueryOpen runs. I found that if the field is set to null at end the WebQuerySave or in the WebQueryOpen, the message is not displayed.

I’m therefore interested in how the field might be set to null if this cannot be done in the WebQuerySave or WebQueryOpen.

Thanks.