# Query custom functions automatically in FileMaker

**URL:** <https://the.fmsoup.org/t/query-custom-functions-automatically-in-filemaker/2741>\
**Category:** MBS Plugins\
**Tags:** custom-function\
**Created:** [February 6, 2022, 8:27am UTC](https://the.fmsoup.org/t/query-custom-functions-automatically-in-filemaker/2741 "2022-02-06T08:27:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [February 6, 2022, 8:27am UTC](https://the.fmsoup.org/t/query-custom-functions-automatically-in-filemaker/2741/1 "2022-02-06T08:27:10Z")

</div>

We have clients with lots of custom functions in various FileMaker databases. How would you automate this to track custom functions used in various files?  
 ![](https://www.mbsplugins.de/image/CustomFunctionsDialog.png)  
For [MBS FileMaker Plugin](https://www.monkeybreadsoftware.com/filemaker/) 12.1 we got two new functions for this: [FM.CustomFunctionsList](https://www.mbsplugins.eu/FMCustomFunctionsList.shtml) and [FM.QueryCustomFunctionsList](https://www.mbsplugins.eu/FMQueryCustomFunctionsList.shtml). Those functions do a bit of GUI scripting on macOS to get the list. The user needs of course permissions to open the dialog and the menu entry into the menubar for the plugin to click.

The first example script will first trigger the seconds script to run in a second. Make sure the fmplugin extended privilege is checked, so the plugin is allowed to run a script. Once that is set, we run the [FM.QueryCustomFunctionsList](https://www.mbsplugins.eu/FMQueryCustomFunctionsList.shtml) script to start the plugin function to do its job. The script now has to end, so FileMaker allows the custom functions dialog to show. Here is the complete first script:

# schedule script to read results in a second  
Set Variable [$r ; Value: MBS( "[FM.RunScriptLater](https://www.mbsplugins.eu/FMRunScriptLater.shtml)"; 1; Get(FileName); "show result") ]  
# now start query  
Set Variable [$r ; Value: MBS("[FM.QueryCustomFunctionsList](https://www.mbsplugins.eu/FMQueryCustomFunctionsList.shtml)") ]

If everything works right, the dialog shows for a fraction of a second. The plugin copies the list of the table and stores it internally in a global variable. Then our second script runs, which can use [FM.CustomFunctionsList](https://www.mbsplugins.eu/FMCustomFunctionsList.shtml) function to query the list:

Set Variable [$list ; Value: MBS("[FM.CustomFunctionsList](https://www.mbsplugins.eu/FMCustomFunctionsList.shtml)") ]  
Show Custom Dialog ["results" ; $list)]

If the list is empty, the function failed to run properly. For example if there is a custom menu and no menu entry to edit the custom functions.

Please try it. It may help you to automatically query the list of custom functions and then write that information into records. A way to monitor which file uses what custom functions. You can use Evaluate() to run those custom functions dynamically. That is of course only useful if you have some global variable or parameter to switch your custom functions to return some metadata like their version.

Have fun and thanks to Nils Waldherr for the idea!
