JavaScript Functions in FileMaker

JavaScript Functions for Speed and Profit

The movie below is from one of our most popular demos from “Year in Review” at DevCon 2014. I was talking about what a breakthrough custom functions were back in 2004 and how they unlocked a whole new kind of code-sharing among FileMaker developers. JavaScript functions in FileMaker may unlock even more potential.

Jason Young introduced the idea of using JavaScript as a calculator–as a library of functions–instead of using it for perhaps the more obvious purpose of building interface elements. (Jason’s original article on this can be seen as part 1 of this post.) This gives us a huge opportunity to share and borrow code from the immense catalogue of JavaScript functions and examples.

FileMaker Custom Functions Forum
FileMaker engineers start posting custom functions to a public forum: March 2004

As just one example, we (Jason) rewrote the venerable “namwoB” function in JavaScript. namwoB was the first recursive functions I ever saw and was posted by Andy LeCates back in March of 2004. The title comes from Court Bowman’s name spelled backwards… which is all the functions does, rewriting a string of text in reverse. This simplicity makes it a great way to talk about the different kinds of recursion in FileMaker and what a faster version of the function might look like in JavaScript.

Our example file shows the same recursive custom functions done as a “stack” recursive function (limited to about 10k loops), as a “tail” recursive function (limited to 49,999 loops), and as a JavaScript function executed in a webviewer and then passed into a FileMaker script.

Download the example file

JavaScript Functions in FileMaker are Fast

Looping through 49,000 characters took our tail-recursive custom function almost 3 seconds.

The JavaScript version of the function looped through 10 times that much text–nearly 500,000 characters–in 3/10ths of a second.

And thanks to the improved fmp url in FileMaker 13, we can grab the results of functions like these quite easily. The movie below demos this and walks through our example file. It also gives a nice side-effect-demo of how webviewers get their own thread in FileMaker Pro and what that may mean for trying to measure performance.

Featured Posts

Follow Along

Stay up to date with the latest news & examples from SeedCode


  • David

    Hi I am trying to learn this technique but some how it is not working for me. I have tried sample file in FileMaker 13 and it crashes. In FileMaker 14 and 15 my Mac swaps memory as crazy and the system becomes unresponsive. I am using El Capitan. Could it be that Webkit is leaking memory? Any help will be appreciated. Thank you

    • seedcode

      Hi David, It requires 13.0v3 or higher so that may be the issue in 13. You can also probably get past the speed in 14 and 15 by using < 49K characters in the JS example. Start with a few hundred characters and you can still see how it works. (On my FM15 machine it hung the first time I opened it and tried 49K characters, after closing and re-opening FM15 it seems fine and does 49,999 characters in 0.39 seconds.)

  • Richard

    This is excellent. Maybe this will encourage Filemaker Inc. to include Javascript natively in Filemaker in some future version.

    • Jason Young


      • Andy Frazier

        Oh, yeah…a native ExecuteJS() function gets my vote!!

  • Thanks for posting this demo and making a video, John (and Jason). I appreciate how much time it takes to develop new techniques like this and then find the time to properly share them on the web. I’m sure the rest of the FM community likes it, too!

  • Great stuff, as ever, John! It’s really wonderful to see the FileMaker community getting excited about the huge potential of JavaScript.

    On our end, we’ve been busy cooking up some new techniques we’ll be sharing soon as well. Looking forward to trading our best ideas and exploring new uses of JavaScript together as a community!

    • seedcode

      Luv your stuff, Brian!

  • Thanks John. This is very cool and it makes me wonder about using Javascript to parse FMP fields using regular expressions, which is not easily done natively in FMP.

Leave a Reply

Your email address will not be published. Required fields are marked *

Check out some of our other posts ...

Improved Resource Selection

We’ve made some big changes to how you filter and assign resources when editing events in DayBack. These changes will make it much easier to

Suggesting Appointment Slots

Show Available Slots that Match Multiple Criteria Schedulers often look for gaps in their schedules to find the open resources for each opportunity. But sometimes,

Introducing Draft Settings Mode

Following up on this idea that people stretch themselves when they feel a little safer, we’ve been very focused on the customization experience for DayBack

New Longer Timescales for DayBack

Resource Scheduling Swimlanes You can now extend the pivoted scheduling view in DayBack to show items by week instead of solely by day. This lets



Stay up to date with the latest news & examples from SeedCode

© 2024 SeedCode, Inc.