Check for related record

Check for related record

Very often you want to check in your scripts if there is a related record.
For example: before going to a set of related records…
In the past I always used the IsValid() function for that: IsValid ( TO_TO::ID )
But in fact this is NOT the correct way to do it… I’ll explain.

If you look in the Help of FileMaker, nothing there says that the IsValid() is doing that. The IsValid() function was made to check if the contents of a field is valid. Example: the date in a date field is valid, or: there are only alfa characters in a numeric field.

This said, it is perfectly possible that a check on a related field with the IsValid() function returns a ‘False’ even if there is valid related record. Also: IsValid (“”) = True, because there is nothing wrong with an empty field…

So, to check if there is a related record, it is better to use the ‘Not IsEmpty()’ function on the related primary key field: Not IsEmpty ( TO_TO::ID )

See also the article of SixFriedRice:

Jan Stieperaere