Skip to content

Python Native Functions

Simon Brown edited this page Sep 21, 2025 · 3 revisions

These functions give Python scripts access to data in FileMaker.

Before using you must import the class into your environment:

import fm

fm.evaluate (expression)

Evaluate a FileMaker expression, returning any results as a Python object. Since FileMaker globals can be set with this it can be used both to set and get values from FileMaker.

Here's a trivial example of a Python function to set a FileMaker global:

def set_global_to_text():
   fm.evaluate ('$$myGlobalName = "text"')

This function does not work correctly in bBox 1.06.

fm.executesql (expression, values=None)

This Python function calls back to the FileMaker engine to evaluate your SQL expression, and returns a Python list object with the results.

For example, we can execute this in Python:

r = fm.executesql ("SELECT id,name FROM EXAMPLE")

and get back a result like this:

((95.0, u'last went to sleep'), (90.0, u'calendar for year'))

The optional values parameter is a list of one or values that will be used as SQL parameters. Here we’ll create a new record in the SCRATCH table with the values from the Python variables id and filename:

fm.executesql ('INSERT INTO "SCRATCH" (text_1, text_2) VALUES (?,?)', [id, filename])

fm.run (filename, scriptname, {parameter})

Runs a FileMaker script with given script & file name. An optional parameter may be passed in.

To get the script’s result, use:

fm.evaluate ("Get (ScriptResult)")

Clone this wiki locally