BaseElements Custom Function Causing Issue with Hook Call - crashing DataAPI

Hi @BetterForms!

Wanted to make sure I got this into the support channel, as it was pretty darn hard to track down and I figured I could save someone the trouble. @Delfs was kind enough to spend some time with me yesterday trying to locate a bug that was causing some bizarre behavior. Here’s what was happening:

BF App Page has an onUtility save hook that pushes data back to FileMaker. Firing that hook from the BF Page would cause a massive CPU jump on the server, which in turn would shut off the Data API completely.

Trying to debug, we went to the BF_Helper file and ran the exact same hook, that just blew up the whole system, and it ran perfectly fine.

Wtf? Let’s look at the scripting.

In looking at the FileMaker onUtility hook scripting, nothing appeared out of the ordinary. We were simply setting field data using the $$BF_MODEL data. However, there was one line of code that was extracting an array count out of the model data using a BaseElements custom function - BE_JSON_ArraySize. Since this custom function doesn’t technically exist in the custom functions area of the system, and is rather loaded by the plugin, this makes it a stick of dynamite to running the action through the API. We replaced that custom function with ValueCount (JSONListKeys ($arrayGoesHere ) , and the hook now runs fine from anywhere.

I’m sure plenty of you already know this could be an issue, but for those of you who don’t - save yourselves the time and trouble trying to track down what is causing your hook to fail from the api, but not from the helper file. And thanks for your help @Delfs!

Thanks for this update @itsjakefromstatefarm

Owen Reese:
Fascinating, thanks for sharing. It makes sense but not something I would have considered in my scripting either.

Thanks, I now will avoid plugin based script steps whenever possible in BF hooks

Really threw me for a loop @Owen Reese!