Miscellaneous Functions
Utility custom functions for FileMaker solutions.
Introduction
These miscellaneous custom functions provide essential utilities for FileMaker development. They help with script environment information, JSON validation, and handling null values in calculations.
These utility functions are used by the error handling custom functions from Proof+Geist and provide foundation capabilities for working with JSON, script environment information, and null values.
Functions
getScriptEnvironment
Description: Returns a JSON object containing information about the current script environment, including file name, script name, layout, and system information.
Parameters:
- None
Return:
- A JSON object with environment information
Example:
Generated JSON Structure:
JSON.isValid(json)
Description: Validates whether a string is properly formatted JSON. Returns True if the JSON is valid, False otherwise.
Parameters:
json: The JSON string to validate
Return:
- Boolean (True if valid JSON, False if invalid)
Example:
lookupFieldValue(targetField; matchField; matchValue)
Description: Retrieves a single value (first result) from a related table using ExecuteSQL. This provides a clean, portable alternative to the standard FileMaker lookup functionality.
Parameters:
targetField: The field to retrieve the value frommatchField: The field to match against in the WHERE clausematchValue: The value to match in the WHERE clause
Dependencies:
SQL.GetColumn- For executing the SQL query
Return:
- The first value from the result set (or empty if no match found)
Example:
null
Description: Returns a true null value that can be used in place of empty strings in situations where an empty string would cause errors, such as when setting date fields or working with JSON.
Parameters:
- None
Return:
- A null value (the undefined default result from a Case statement)
Example:
Common Use Cases:
Usage Tips
-
Environment Information: Use
getScriptEnvironmentfor consistent error logging or debugging to capture the context in which operations are performed. -
JSON Validation: Always validate external JSON data with
JSON.isValidbefore attempting to parse it to prevent errors. -
Database Lookups: Use
lookupFieldValueas a more flexible alternative to relationship-based lookups, especially for ad-hoc queries where creating a relationship would be impractical. -
Null Values: Use the
nullfunction instead of empty strings when:- Setting container, date, time, or number fields to empty
- Creating JSON with null values
- Working with APIs that expect null rather than empty strings