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:
-
Add a computed field (‘MessageField’) to the form. Surround this with a tagset. Mark the field and tagset as ‘Pass through HTML’.
-
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.