Most web browsers have facilities to help developers find problems in their code. Safari is no exception, with built-in debugging tools as part of its WebKit browser engine. It turns out if you are using macOS you can get the same facilities found in Safari to also debug your code that’s running in a FileMaker web viewer.
Enabling Web Inspector
To do this we need to first enable a hidden option. Quit any open copies of FileMaker and start up the Terminal app to execute one or more versions of the command below.
Quit FileMaker if open, otherwise it will overwite the plist change that we’re about to make to enable WebKit debugging.
For FileMaker Pro 19, type or paste this into the terminal. And…yes, advanced12 is the correct parameter for version 19:
defaults write com.filemaker.client.pro12 WebKitDebugDeveloperExtrasEnabled -bool YES
For FileMaker Pro 18 and older, check out this blog post.
Debugging Using Web Inspector
With your plist changes made, start FileMaker Pro back up, and navigate to a layout containing a web viewer. Make sure that Allow interaction with web viewer content is enabled. Now, back in Browse mode, right-click on a Web View, and select Inspect Element from the contextual menu.
One issue is that the debugger will go away whenever the Web Viewer is not displayed. Annoyingly, this also clears any previously set breakpoints.
A partial list of functions are:
- console.assert(expression, object)
- debug (expression)
None of these debugger functions will work until the Web Inspector has been activated, so enable it as soon as possible with the contextual menu on the web viewer. But at least the debugger breakpoints will persist each time the web viewer is reloaded.