Display ExecuteSQL Results in a Web Viewer

In a previous blog post (How to Display FileMaker Data Online), I wrote about how to export data from a FileMaker database into a table hosted on a website using DataTables. DataTables can also be used with FileMaker to create a layout that displays the results of your ExecuteSQL queries.

DataTables can be useful for displaying ExecuteSQL results in a web viewer in FileMaker.
The table is responsive when resizing the window

Exporting Data into DataTables:

I’ve included a demo file at the end of this blog post.

This method:

  1. Queries your database using the ExecuteSQL() function
  2. Converts the results to JSON
  3. Prepares the DataTable code and exports it to an html document
  4. Displays the data in a web viewer

This entire process should take less than 200 milliseconds.

Other uses:

In the demo file, I’ll export the HTML and JavaScript code into a temporary file, then display it in a web viewer. You can choose to open the file in your default web browser using the Open URL script step. You can also send the file to someone for reporting purposes, etc.

Limitations:

  • The demo file is not compatible with FileMaker versions prior to 18, because it uses data files (click here for more info). You can make the demo file compatible with older versions by changing the script so that it directly copies the HTML content into the web viewer.
  • An error message may pop up for Windows clients due to limitations with IE11. The demo file was tested only on MacOS. Please let us know if you encounter such an error.

Going further:

  • Geist Interactive has thorough blog posts about using DataTables with FileMaker.
  • You can find information about customizing the style of your table here.

Conclusion:

This method is a quick way to display data returned by ExecuteSQL in FileMaker without having to create a layout or a report script for each set of data that you’d like to generate.