Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3305 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi all

I'm having a little trouble here trying to validate fields using the OnObjectValidate Script Trigger. All aspects of my validation script works well apart from my test if a field is empty. If a field has not been modified the OnObjectValidate does not trigger the script when tabbing out of the field.

I have used on OnObjectExit Script Trigger to run a script that solely checks if the field is empty which solves the problem to an extent. The problem arises if the user never actually enters that field by using mouse rather than tab.

I do not wish to use the native validation for mandatory field as I would like all my dialogs to use the same format.

Anybody got any suggestions?

Thanks in advance

Lee

Posted

Well, the thing is that Filemaker validates mandatory fields on record commit. This is necessary because as you noted, the user may not even enter the field - but still, the field should not be empty.

The problem is actually more complex, because the field is also validated when modified; however, this validation skips the 'Not empty' requirement, giving the user a chance to fill in a value later. OTOH, a validation still occurs, so a script triggered OnObjectValidate is launched.

I haven't found a good solution to this yet. Obviously, it is necessary to run a script both on OnObjectValidate (if the field has other restrictions) and OnRecordCommit. But covering all possible scenarios, esp. when many fields are validated in different ways, can be difficult.

Posted

Hi Lee,

Another option is to use layout triggers for your validation. A User can't even exit FileMaker without properly meeting your requirements and the validation test only runs upon attempt to leave the layout. It is fairly safe but you must protect from ALL occurrences of the field on any other layout if enterable (even if displayed through relationships) if you don't use field- or privilege-level protection.

Here is a sample which uses layout trigger (see Layout Level > Script Triggers tab). It's just something else to consider.

LayoutValidation.zip

Posted

Thanks Comment

I have opted to use three triggers, OnObjectValidate, OnObjectExit and OnRecordCommit.

OnObjectValidate - All validation apart from mandatory field validation

OnObjectExit - Mandatory field validation when tab is used.

OnRecordCommit - Any mandatory fields that have been skipped using mouse.

Lee

Edit: Sorry and thanks LaRetta just seen your post - will investigate

Posted

Hi LaRetta

Thanks for the test file.

I have been asked if possible to validate field by field rather than on commit.

I have used a technique quite similar. In my solution the user cannot exit certain layouts unless a submit or cancel button has been clicked. I ended up adding the mandatory field check within the script attached to the submit button and also OnObjectExit to warn the user if they are tabbing through.

Lee

Posted

Indeed, there are many options. I should mention also that new record creation should be scripted (as it should anyway) if using data-entry validations based upon layout. Keeping it simple, new record script would be:

If [ Get ( RecordNumber ) ]

Perform Script [ Layout Validation script ]

End If

New Record/Request

We use various permutations depending on rigidity of requirements.

  • 4 years later...
Posted

An old thread that helped me great deal, am trying to mimic the behavior of the search medicine on FDA web site inside my emr solution and i was struggling with this particular issue and you both LaRetta and Comment solved it ….Thank you..!

This topic is 3305 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.