Validation rules have no effect on whether a script does or does not execute. The script would need to check the value of the field(s) to determine whether or not to run.
I would take a look at the OnObjectValidation trigger as a way to perform a script that validates the data in the field and handles user errors in a more user friendly fashion. This script can use Exit Script [False] to keep the user action--clicking the button, that tripped the trigger from being processed by FileMaker.
Still no joy, through a number of configurations surrounding OnObjectValidation and Exit Script [False].
Either i can get it to do nothing, or the original result, but not the desired result.
I would think on object validation is what i want, but i need to prevent the button from being able to be pressed unless the field validates successfully.
Exit Script [False]
will prevent the button click.
If I just place Exit Script [False] in the OnObjectValidation trigger it prevents me from moving out of that box even when the value is correct.
That is correct. You want to use this option for when you want to return the user to the field in order to correct it. So you use an If block where this is used to cancel out the button click when there is an error, but keep it from being executed when there is not an error.
Set Error Capture [on]
If [Get ( LastError ) // there was a validation error
Revert Records [no dialog ]
Show Custom Dialog ["there was a validation error"]
Exit Script [False]--> this step keeps the button click from being processed, but only if an error is detected
If control passes to this part of the script, no error was detected and the button click event is processed.
One last weird thing that I am experiencing with this setup.
When I do click the button, it appears that all of the steps in the script activate, but then I get a pop-up asking me if I want to "Save changes to this record?" with options for dont save, save, and cancel.
If I do click save, I can effectively work around field validation and save a totally incorrect value.
Sounds like your layout is configured to disable automatic saves.. If so, use the "no dialog" option for commit records.