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

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,
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

marilyngConnect With a Mentor Commented:
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?
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.

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

BroadAustraliaAuthor Commented:
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


How are you doing with this?
BroadAustraliaAuthor Commented:
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 ;)

BroadAustraliaAuthor Commented:
Hi Marliyn

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

All Courses

From novice to tech pro — start learning today.