Type coercion in FileMaker: GetAsNumber, GetAsText, GetAsDate
BeginnerFileMaker fields have types, but calculations sometimes return the wrong type for the context. Learn how GetAsNumber, GetAsText, and GetAsDate coerce values and why type mismatches cause silent bugs.
What you'll learn
- When and why implicit coercion fails silently in FileMaker
- How GetAsNumber, GetAsText, and GetAsDate force the correct type
- The pattern for checking whether a value is a valid number
FileMaker performs implicit type coercion in some contexts and not others — using GetAsNumber, GetAsText, and GetAsDate explicitly ensures your calculations behave predictably regardless of field type.
1/3
1
Convert text to a number for arithmetic
If a value comes from a text field or a JSON parse, wrap it in GetAsNumber before arithmetic. Text that cannot be converted returns 0, not an error.
FileMaker Script
# $quantity comes from a JSON parameter — it may be a string Set Variable [ $qty ; Value: GetAsNumber ( JSONGetElement ( $param ; "quantity" ) ) ] Set Variable [ $price ; Value: GetAsNumber ( JSONGetElement ( $param ; "price" ) ) ] # Safe arithmetic — both values are confirmed numbers Set Variable [ $total ; Value: $qty * $price ]
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo