Manage Learn to apply best practices and optimize your operations.

Best practices for using the Lotus Notes WebQuerySave agent

SearchDomino.com member Sameer Thakur explains common pitfalls associated with using WebQuerySave agent and how to avoid them when validating data on a Lotus Notes form.

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 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.

  • Dig Deeper on Lotus Notes Domino Agents

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.

    -ADS BY GOOGLE

    SearchWindowsServer

    Search400

    • iSeries tutorials

      Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

    • V6R1 upgrade planning checklist

      When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

    • Connecting multiple iSeries systems through DDM

      Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

    SearchDataCenter

    SearchContentManagement

    Close