Best practices for using the Lotus Notes WebQuerySave agent

Best practices for using the Lotus Notes WebQuerySave agent

The conventional way of validating data entered on any Lotus Notes form is to run a WebQuerySave agent. However, if any data is not confirming the expected values, an error message gets thrown to the user.

But the problem of running the WebQuerySave agent is twofold. Either we have to redirect the user to another page -- or take the user to the original form. Unfortunately, either approach causes data entered by the user to be lost forever. The user then has to enter the data again.

To avoid this pitfall, follow these steps:

  1. In the "Computed for display field," use the name "errMsg." Make sure that the formula has the same field name as itself.

  2. Turn the JavaScript function "on" for the Onload event of the form. This function will check the value in the "errMsg" display field. If it contains any value, it will alert that value and make it blank.

  3. Use the modified WebQuerySave agent. This Lotus Notes agent will be now modified. Any print statements written inside will be removed. It will set any message in the "errMsg" field and exit. At the conclusion of the agent, it will set "SaveOptions" to "1" or "0" -- depending on the success of the validations.

  4. Set up the hidden validate button with the following formula:
    @Command([ToolsRunMacro];"YourAgentName");
    @if(SaveOptions="0";
    @Command([FileSave]);@Return(@False));
    
  5. Remove the agent call from the WebQuerySave agent.

  6. Click the "SaveButton" -- or

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

  1. any other button that can invoke a form submission -- instead of submitting the form call click of the validate button. This will run an agent and set your "SaveOptions" accordingly.

If SaveOptions is set to "0," this means validations have been successful and it will save the form -- or else do nothing. In that case we have already set "errMsg" in an agent and after execution of the agent, the Web page gets refreshed and our Onload script will give an alert with the error message we set. This all happens without losing any data.

There is no need to use Ajax or any preloaded data for a client-side comparison. You should do your validations on the server and give alerts to your Lotus Notes users.

Do you have comments on this tip? Let us know.

Related information from SearchDomino.com:

  • Expert Advice: Getting WebQuerySave agent to run
  • Expert Advice: Referencing a view
  • Reference Center: Agent tips and resources

    This tip was submitted to the SearchDomino.com tip library by member Sameer Thankur. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

    This was first published in March 2007

  • Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.