profile

ScriptLogic

Create better FileMaker scripts by giving me a few minutes every day thinking about techniques and deepening your understanding.

Subscribe to receive every post as soon as it’s released…

One script to manage a process

One of the most common script patterns that I use is when I have a process with a number of actions. In many cases this is a script to manage a particular entity. So actions can be any of Open, Add, Edit, Save, Cancel and Exit. Each action will perform a discrete series of script steps. For example, the Open action may open the current record in a card window; the Add action may open the same card window and create a new record. This pattern means that all buttons associated with the process...
READ POST

Loop, but just once.

A loop is a standard structure in programming. It is designed to process a block of code a number of times until a condition says to stop. A loop has three essential parts: a starting point, the code to repeat and an exit condition. A loop may work through a set of records, a set of fields in a record, or a block of text such as JSON. It may also be used to retry an operation, build a list, or check a condition until it becomes true. try/catch Another programming structure available in many...
READ POST

Are your FileMaker scripts idempotent?

Idempotency? Eedemwhat? Huh? Never heard of it? It is pronounced either ee-dem-po-ten-see or id-em-po-ten-see. Any process is idempotent if applying it multiple times has the same effect as applying it once. In real life, an example is pressing the button to cross at a pedestrian crossing. When someone presses the button, it registers a crossing request. The pedestrian walk indicator is added into the light changing schedule. If someone across the road also presses the button, there is no...
READ POST

Are you using a supported client version?

Each major release of FileMaker Pro brings new features. These features necessarily include new script steps and new functions. Importantly, existing script steps and functions are often also updated. New versions and new features present an issue for FileMaker developers. If we choose to use the new features, we need to make sure that the user is accessing our solution with the right version of the FileMaker client. In most cases, the solution will be hosted, so we also need to ensure that...
READ POST

Debugging Scripts with Assertions – Access Control

Over the last couple of days we have come to understand assertion and have created a script that we can call when we want to assert. This requires just one line in our calling script – Perform Script specifying a JSON parameter with two elements, condition and message. Required control Today's challenge is controlling when assertions run. Assertions are a developer tool, not part of normal application behaviour. We need a way to control when they run. On one hand, we can specify that the...
READ POST

Debugging Scripts with Assertions – Abstracting the Assert Process

Yesterday we looked at the concept of an assertion for debugging, and the structure of an assertion in a FileMaker script. Now we will look at a better method of scripting assertions for portability and flexibility. The Assert script Instead of adding a dozen script steps for every assertion, we are going to abstract the assert process to a subscript. This subscript can be called from any script with two parameters – condition and message. condition is a FileMaker calculation expression...
READ POST

Debugging Scripts with Assertions

Assertions are a debugging technique that helps the developer detect incorrect assumptions as soon as they occur, rather than hundreds of lines later when something finally fails. An assertion can be a simple check to confirm if a condition is true. Simple assertions can be used to verify input values, output results, or current states. An assertion says: “At this point in the script, I expect this condition to be true.” If it isn’t, something has gone wrong. When an assertion fails, the...
READ POST

Teaching card windows new tricks

Practically every new release of FileMaker has that one amazing new feature. Back in May 2017 when FileMaker 16 was released, my favourite new feature was the card window. Card windows A card window is a clean window that is attached to the parent window from which it was created. It has none of the chrome that displays at the top of normal windows – title bar, status toolbar and editing bar. There may be a close button at the top left but this can also be removed. A card window is modal,...
READ POST

Better Boolean Tests: True means go

There are many situations in FileMaker where you will use a Boolean expression. This is an expression that evaluates to either True or False. In scripting, the most common place for a Boolean expression is in an If statement. Is it true that...? If we are testing for an overdue item, we can write: If [ itemReturnDate < Get ( CurrentDate ) ] Perform Script [ "Run overdue process" ] Else # ignore the item End If The Boolean expression in the If statement evaluates to True when the item return...
READ POST