Input Validation - how to stop Save & Close action when verification done in QuerySave?

Posted on 2006-07-17
Last Modified: 2013-12-18
Hi Experts!

I was doing my field verification under each field - and had a Save & Close action with the following formula:

Now I have moved my field verification to Lotus Script in the QuerySave of the form ( so it is all in the one area and it is now conditional on other fields ).

BUT ;)  now when I choose Save & Close the QuerySave runs -- telling me what fields I am missing and the document is closed by the action - not allowing the user to fill in these required fields.

Here is the validation in Lotus Script QuerySave event:
            Elseif doc.LeWrapUp(0) = "" Then
                  Messagebox("Please enter WrapUp code." )

I could make seperate "Save"   and   "Close"  buttons - but surely there is a better way??  How can I stop the action if the LS requirements are not met?  Thanks for your help,
Question by:BroadAustralia
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 18

Expert Comment

ID: 17127065
Ok, I assume you've taken the field validation out of the fields?  

In the querysave event, you have the continue = false.

But when you press the action button, guess what, the actions run faster than the querysave values.

So, usually in your action button:
if you have field validation events:
  @PostedCommand([FileCloseWindow])); "")

Sometimes you also have to check if the document has been deleted, too. :)

If you don't have field validations, you can just do the:
  @PostedCommand([FileCloseWindow])); "")

Now normally, when you  start all this the other little irratating dialog box gets in the way, too.  "Do you want to save your changes?"  And if you say, no, it keeps popping up.  So, now you have to trap the SaveOptions in the events.

By placing a field called: "SaveOptions" on the form, editable, default value = "1"  which means to prompt to save if changes are made.

So, now you have th wonderful task of deciding when the user SHOULD be prompted if he or she wants to save the document when they press the ESC key, or if they press CLOSE.

        Usually you set the SAVEOPTIONs in POSTOPEN (if the document is being edited)
        POSTMODECHANGE (if the document is being edited)
        QUERYSAVE (To allow the changes to be saved to the document, and then to reset the value to "0" so users don't get the "do you want to save" dialog box)

       And in the Save and Close action buttons:


  @PostedCommand([FileCloseWindow])); "")

Hope this wasn't too confusing.. and sorry I jumped ahead to the next question.

LVL 18

Expert Comment

ID: 17132070

Author Comment

ID: 17134085
Hi Marliyn

Thanks for the link I will look at the tools.

I need some help with this though sorry I am not getting it   &(   I also have to take it one step of the time I hope it's not to painfull ;)

If I use this formula below in the Save & Close action, the document IS NOT closed ( great ) and then user can then fill out the required field.  But if they don't, or if there is more than 1 field that is required I end up again with the same problem yes??  ( I am missing something? ).  I think so.

  @PostedCommand([FileCloseWindow])); "")

Thanks for your paitence


Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 18

Accepted Solution

marilyng earned 500 total points
ID: 17135131
Kinda.. if your query save does the loops...

So, when you press the action button,
     - it checks to see if there are any field validation events.
     - if it finds any, it stops the processing and does not save, does not close.  User has to fix the
       invalid fields and press the save button again.

-If it passes isvalid, then it moves to the FileSave.  
-If you don't preface this with the "@if" statement  then the filesave happens and moves on to FileCloseWindow before your QuerySAve event processes.

-With the "@if" statement, the querysave event processes.
-In this, I assume you have a list of fields that you want to test,


Sub querySave( source as NotesUIdocument, continue as variant)
     continue = false
     dim chkFieldList as variant
     Dim doc as notesdocument
     set doc = source.document
     ChkFieldList = doc.ChkFieldList
    forall chk in chkfieldList
     if len(doc.getItemValue(chk)(0))<1 then
        'field fails  continue is already false
        exit sub  
    end if
   end forall

'if you get here then
    continue = True
end sub

The querySave exits when the selected fields pass validation, and allow the action button to proceed to the FileCloseWindow.  

However, because you have not addressed saveOptions, the front end save will prompt the "do you want to save" message as soon as you call the "FileCloseWindow"

Does that help any?
LVL 18

Expert Comment

ID: 17211739
How are you doing with this?

Author Comment

ID: 17285470
Hi Marlilyn,

Sorry I missed your follow up on the 31st  "thankyou".  When I couldn't resolve after your 1st post I had to get "something" working as the system was live and I was getting documents with essential missing fields...  ( I just put two seperate buttons  "Save"    and a "Close")     In the mean time I've been dealing with all other sorts of fun things that us lucky IT people get to do ;)

Things like dealing with telecomms providers, backup problems, and other exciting projects too many to list here!!

I am back onto this now ( well, tomorrow now, I guess ) and thanks so much for explaining.  Thanks for your help,

And if I forgot to mention it, thanks ;)


Author Comment

ID: 17314530
Hi Marliyn

Thanks for sharing your knowledge.  Sorry we had some public holidays here & I needed the time off!


Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question