The FileMaker Length Function

From Dwayne Wright PMP
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit or other formatting of the posting may fail. For the best experience, please visit the journal directly by clicking (here).


Length( text)
FMP Version: All recent versions of FileMaker
This function returns the number of characters in a field or text string including numbers, special characters and even spaces. Length is often used for validation ( data is at least x number of characters long ).

EXAMPLE: Length ("LeSaux Media Services")
This example would return a result of 21. This is because I asked for the number of characters of the string LeSaux Media Services.

As odd as it may sound, length can also be used to tell you the file size of an object inside of a container field. The size is returned in bytes and I was skeptical about this when I first heard it but it does work.

EXAMPLE Length(GetRepetition ( linked images ; 1 ))
Here I am using the length function to get the size of the first repetition of a container field called linked images. Many times, a developer will create a repeating field for storing container data in a record. That way they can expand the number of files stored in a record without creating additional container fields.

USING LENGTH AS PART OF FIELD VALIDATION
A real world example is something a fellow developer at SolutionMakers is working on for a customer. He is doing a FileMaker to QuickBooks integration project. In cases like this, QuickBooks does have some length restrictions for some of it’s fields. Company name for example can only be up to 41 characters in length. If you try to send a record with a company name beyond 41 characters to QuickBooks, QuickBooks will reject it. So he has used the length function as part of a field data entry validation in the FileMaker file. FileMaker will alert the user if they type in a company name too long and explain to them why it is not permitted.
=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2007 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.