1answers

Mandatory Values

I have started to understand auto enter and validation field options.

I want to ensure that a field isn't empty AND contains an approved value.

For instance:

  • The field should not be empty (“”, NULL, FALSE, 0, or Empty).
  • The field should contain either the value "Cat" or "Dog".

What are some of the best ways to accomplish this? Should I use value lists or a calculation to validate the field? What about using a script? What is the best sentinel?

The state field must contain a two letter state abbreviation.

Chris Johnston

Answers

I think selecting the "Not Empty" and "Member of value list" validation options for your field are probably your best bet. You could write a calculation to accomplish the same thing, but that would be making more work for yourself, and who needs more work? Also, by validating by value list, you can edit the list of valid values without opening "Manage Database" and starting a schema-locking situation, in case you ever find yourself needing to perform this edit on a live application with active users. (A validation calculation could also reference a value list, but not as easily.)

Validation by script is no substitute for the field-level validation options in Manage Database. A script has to be triggered by some event you have to configure separately in your application. Field-level validation options apply everywhere a field appears, and to every way there is to access the field, including from external applications (PHP, xDBC, etc.), with no need to remember to attach a script to operations that might manipulate the field.

Jeremy Bante

Back to questions