Recursive custom functions

Expert

Write custom functions that call themselves to process lists, traverse hierarchies, and solve problems that loops cannot handle in calculations.

What you'll learn

  • How to write a recursive custom function with a base case
  • How to process a value list item by item with recursion
  • How to avoid infinite recursion with a depth guard

Custom functions in FileMaker can call themselves, enabling recursion. This is the only way to iterate within a pure calculation — without a script loop. Recursive CFs are ideal for processing value lists, walking tree structures, and string manipulation that requires repeated passes.

1/3
1

Structure: base case + recursive case

Every recursive function needs a base case that stops the recursion and a recursive case that calls the function with a simpler version of the problem.

FileMaker Script
// Custom function: SumValueList ( list )
// Returns the sum of all numbers in a return-delimited list

If ( IsEmpty ( list ) ;
  0 ;
  GetAsNumber ( GetValue ( list ; 1 ) )
    + SumValueList ( RightValues ( list ; ValueCount ( list ) - 1 ) )
)

Sign in to track your progress and pick up where you left off.

Sign in to FM Dojo