To generate a unique number within a document and save this computed value, use a Lotus Domino agent that is called by the WebQueryOpen event. The following excerpt from Lotus Domino Designer help text explains how the WebQueryOpen event works:
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."
After selecting the form property "Generate HTML for all fields," the computed number is saved along with all of the other fields in the document.
We wanted to allow only unique city codes to be saved when creating a new unique city code from the Web.
The following excerpt from the Lotus Domino Designer help text explains how the WebQuerySave event works when checking for unique values:
Simulate CGI programs that run on user-supplied data by programming a WebQuerySave event and adding a SaveOptions field with a value of '0' to the form. When the agent runs, you can collect field values from the filled-out form without generating a new Notes document.
Having the SaveOptions set to 0 will keep the document from being saved. As soon as this value is set to 1, the document is saved. There is no need to perform an "if" check on SaveOptions in the submit button. Lotus Domino handles the saving based on the value of the SaveOptions field.
For example, here is the solution we used:
1. In the Form, create a Submit button as well as a hidden field called SaveOptions with an initial value of 0.
2. In the Submit button, code the following formula:
3. In the WebQuerySave event, enter the formula that runs an agent.
4. In the agent, add the following code:
If (foundCityCode) Then
'// The following line will set the SaveOptions on the document as 1 which will cause
'// Notes to save the document.
Set item = doc.ReplaceItemValue("SaveOptions", 1)
Dan Boyum is a Software Engineer on the Business Solution Test team located at the Rochester, Minnesota, laboratory. He has 2.5 years of experience in the software testing field. His areas of expertise include Lotus Domino and Windows servers on iSeries. Dan can be reached at
Marilyn Dukart is an Advisory Software Engineer on the Business Solution Test team located at the Rochester, Minnesota, laboratory. She has over 15 years of experience in the software testing field. Her areas of expertise include Lotus Domino and WebSphere. Marilyn can be reached at