Blog

Software tips, techniques, and news.

User-Defined Custom Business Logic in Claris FileMaker

Business rules inevitably evolve over time. When they do, it's important that FileMaker users are able to adjust their application quickly and easily to keep up. The best way to do this is to allow users to modify and define what information FileMaker is presenting them with and how it should be presented using business logic. Let’s demonstrate how to enable users to define business rules.

youtube-preview

When To Use User-Defined Logic

One use case for user-defined business logic is to give users a way to specify what information they want to be synced between a local copy of a file and a hosted version of the same file. In a file with a lot of tables, it may not be necessary to sync data between the two for every table. However, as the system grows - either through the addition of new tables or the necessity to sync data from previously excluded tables - it becomes difficult to add logic to scripts to account for such changes.

Application

To demo this functionality, we will use a FileMaker application for entering order information. You can download the demo file (located at the bottom of this article) and follow along. 

filemaker user defined logic opening screen.

Click on the plus sign in the top left corner of the tab control. This brings up a card window that will allow users to select which layouts to include.

filemaker user defined logic add layouts button.

In the card window, click the refresh icon in the top right to initialize the layout selector with the layouts currently found in the file. Click on the layout you want to include. In this case, we want to use "order". It should already be selected and will appear in the Sync Layouts tab. 

filemaker user defined logic layout selector.

The next step is to select the primary key for that layout. This field is a dropdown list that works off a value list. The value list is a calculation field that is set to a global variable.

filemaker user defined logic value list.

The value for this global variable is defined in a script parameter that is a script trigger on the primary key selector field. The script itself does nothing, but the script parameter is a let statement that defines the global variable we use for the value list, so it will update dynamically as we click into each portal row.

filemaker user defined logic calculation.
filemaker user defined logic script parameter.

Clicking into the limit criteria box brings up a card window allowing the user to define the logic that the system will use to limit the return data during syncs or, in the case of this demo, finds. 

filemaker user defined logic limit criteria.

**Important notes about the limit criteria: Users are only able to select fields that exist on the layout. They can also type into the box instead of using the insert drop-downs if they prefer.

filemaker user defined logic limit criteria important notes.

The two drop-downs to the left of the edit box contain a list of operators that users can add to modify the query and the list of fields they can select from. After adding their logic, users can view what the JSON data will look like for their query by pressing the preview query button. The run query button is for demonstration purposes and simply runs a find with the given parameters.

filemaker user defined logic json results.

How the Logic Works

This solution uses escape characters to denote items as fields or functions and uses Evaluate to determine the function's value at runtime. To parse the users specified criteria, there is a calculation that builds the JSON data block using a while loop. "[ ]" are used to encapsulate a field name if it has spaces or underscores, "#{ }" is used to wrap a function that needs to be evaluated, "{{New Request}}" is used to perform OR requests. "Omit" marks that section of the query as an omit section.

filemaker user defined logic while loop.

We then use a custom function to evaluate any functions before performing the query.

filemaker user defined logic function.

Conclusion

User-defined logic is a powerful tool that enables end users to adapt quickly to ever-changing markets and rules. This functionality also allows your system to be much more flexible and will lead to less time spent updating scripts to add in new criteria, enabling you to manage and view these settings from one layout. These settings can be used to send sync queries to a hosted app with the data API or, as we demonstrated in this article, to perform dynamic finds.

If you would like to learn more about integrating user-defined logic in your Filemaker application or how adding it into your system can help your business run better, contact our team at DB Services and we'll gladly help you find the right solution for your business.

Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.

Download the User-Defined Custom Logic File

Please complete the form below to download your FREE FileMaker file.

FileMaker Experience *
Terms of Use *
OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This file is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free file, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.
michael wyda headshot.
Michael Wyda

Michael is an approachable and reliable developer who is passionate about making a positive difference in people’s lives. His collaborative approach and genuine desire to help others succeed allow him to make lasting connections with both team members and customers while working towards a common goal.