8 Replies Latest reply on Mar 18, 2013 1:26 PM by philmodjunk

    Revert Record and Field Validation do not work in conjunction with each other

    JohhnyHilly

      Title

      Revert Record and Field Validation do not work in conjunction with each other

      Post

           In my limited experience I have found that Revert Record and Field Validation under Manage Database do not work in conjunction with each other.

           Since there are only 2 options under Validation, "Always" or "Only during data entry" that means whenever you click outside a field once data has been entered, the data is commited to that record. If at this point you then Revert Record and go back to the state before the data was entered in that field, I found that the data is still there meaning the Revert Record doesn't work.

           Does anyone have thoughts on how to get it to work? The reason I ask is that I have one layout for display, and another for editing that info. If I am on the edit layout and realise I have made a mistake entering data I want to click a cancel button (revert record) to take me back to the original state so I can start again. The same goes for an automatically generated ID number, if the number is generated then I want to revert the record, that ID number still exists.

        • 1. Re: Revert Record and Field Validation do not work in conjunction with each other
          philmodjunk
               

                    If at this point you then Revert Record and go back to the state before the data was entered in that field, I found that the data is still there meaning the Revert Record doesn't work.

               That's because revert record reverts the record's uncommitted data restoring the record to the data present the last time it was committed. When you click the layout background you are committing the record and thus there is nothing left to revert.

               But any validation errors should interrupt the commit record action and present you with the option to revert the record. This will not, however, roll back the serial number field's next serial value setting. Often such "gaps" in the serial number are not a major issue. The exception is when you need a gap free series of values for auditing purposes.

               To make the validation process more user friendly, there are two options you can work with:

                 
          1.           Use the OnObjectValidate trigger to perform a script that responds to and processes possible errors before the validation rules are evaluated.
          2.      
          3.           Set up a group of fields with global storage specified. When a user clicks a save button on your layout, your script then validates your data and then, if all is valid, creates a new record and transfers the data from the global fields to the corresponding fields of the newly created record.
          • 2. Re: Revert Record and Field Validation do not work in conjunction with each other
            JohhnyHilly

                 Ok thanks for clearing that up. Maybe it's something Filemaker should look at, as to me it doesn't make sense why there wouldn't be an option for the validation of an entire record, no matter how many fields are on that record.

                 Anyway, to keep it as simple as possible I guess option 1 you suggested would be best. Are there any threads or posts I could read up on this? As I wouldn't know where to begin with that script.

            • 3. Re: Revert Record and Field Validation do not work in conjunction with each other
              JimMac

                   The problem with any Revert/Redo like a word processor falls apart when you Share or HOST you database. Once a record is committed, other Users  can access that record. surprise

                   Try to Revert a Debit card withdrawl after the ATM comittied $100.  So FM will not change this in near future.wink

                   Jim...

                    

              • 4. Re: Revert Record and Field Validation do not work in conjunction with each other
                philmodjunk

                     I don't have a link for such an example, but I can share this trick. With the OnObjectValidate, if you terminate the script with:

                     Exit Script [false]

                     Validation never occurs, the record is not committed and the user is returned to browse mode with the cursor/focus back on the field set up with the script trigger.

                     Thus, one simple scripted option is simply to show a custom dialog telling the user their error and when they click OK, it leaves them back in the field to correct the error.

                • 5. Re: Revert Record and Field Validation do not work in conjunction with each other
                  JimMac

                       @Phil  Careful you don't let the USER ever have control inside that script, otherwise I think he can commit a record even though a single specific field in that record hasn't been validated.  Also I think the Server can disconnect a USER on time and commit a record without validations.  Thats kinda like a power failure.

                       Jim...

                  • 6. Re: Revert Record and Field Validation do not work in conjunction with each other
                    philmodjunk

                         @jim, this would be pretty much an "eye blink" script. Even without allow user abort [off], I doubt that anyone short of superman could successfully interrupt the script. It's basically just a way to show a customized validation error message in ways that the current validation message box in field options can't do.

                         And the server could only disconnect and commit the data "on idle"  if this is set up as a permitted option in the user's privilege set, but definitely one to be aware of...

                    • 7. Re: Revert Record and Field Validation do not work in conjunction with each other
                      JimMac
                           

                                 

                           

                                Thus, one simple scripted option is simply to show a custom dialog telling the user their error and when they click OK, it leaves them back in the field to correct the error

                           @Phil it was the Show Custom Dialog which MIGHT give USER control.  Plus I have a accountant that can find any bug, she must be wonderwoman!  I have a 10 year old tested DB that double accounted [last month] using GTRR and a found set being Changed by another rare action [not traceable on Debugger].  That took me 10 days to find that one because the FOUND set was Released during the accounting part.surprisecrying.  The script was written prior to being put on a Sever.  Thus, I wanted to chime in about Record commited and Releasing in a SERVER environment.

                           Jim...

                      • 8. Re: Revert Record and Field Validation do not work in conjunction with each other
                        philmodjunk

                             Yet the script looks like this:

                             Say you want to catch cases where a number less than zero is entered:

                             If [YourTable::NumberField < 0 ]
                                Show Custom Dialog ["Values entered in this field cannot be less than zero."]
                                Exit Script [False]
                             End If

                             It's pretty hard to for any user to interrupt that script....