JSON, Level: Advanced, Version: FM 18 or later

FM18: JSON.UpdateArrayElement

Disclaimer: the technique shown in this article is an attempt to work around an annoyance that can crop up when using FileMaker’s native JSONSetElement function, and is provided on an as-is basis. Use with appropriate caution and at your own risk.

Acknowledgement: I owe a debt of gratitude to Paul Jansen for many illuminating JSON-related discussions over the last year or so. Thank you Paul.

Bug fixes: Demo file has been updated to v3.

Introduction

Today we’re going to look at a custom function, JSON.UpdateArrayElement, written to circumvent a problem you may encounter when using JSONSetElement. (Note: see Thinking About JSON, part 1 and part 2 if you need a basic FM/JSON overview or refresher.)

Demo file: JSON-UpdateArrayElement-v3.zip (requires FM 18 or later)

2019-08-13_16-02-58.png

Why did I write a custom function to do what JSONSetElement apparently already does? Because under certain circumstances JSONSetElement does not work the way I believe it should. We’ll get to the custom function in a minute, but first there are a couple issues we need to examine. Continue reading “FM18: JSON.UpdateArrayElement”

Level: Intermediate, Version: FM 18 or later

New in FM 18: While, part 2

Today we’re going to dig a little deeper into the new-in-18 While function, and to avoid repetition, will assume readers are familiar with last month’s article on SetRecursion and While. We’ll look at some new examples ranging from basic to advanced, investigate the circumstances under which While can use variables previously declared via Let, and check out some benchmark results comparing While vs. CustomList.

Demo Files

Continue reading “New in FM 18: While, part 2”

Level: Intermediate, Version: FM 18 or later

New in FM 18: SetRecursion and While

Author’s note: Inevitable comparisons will be drawn between the new While function and the venerable CustomList custom function, which I wrote about at length several years ago. Preliminary testing indicates that CustomList is faster under certain circumstances and While is faster under others. In my opinion, both of them belong in your developer tool kit.

Today we’re going to take a look at two new functions introduced in FileMaker 18: SetRecursion and While, and you can follow along in today’s demo files if you are so inclined.

maclaurin-series.png

Demo files: While-Sandbox.zip and Maclaurin-Series.zip

Continue reading “New in FM 18: SetRecursion and While”

JSON, Level: Advanced, Version: FM 16 or later

Magic Portals

Today we’re going to look at a design pattern I’ve recently been using to accommodate a client request. The request is to be able to view and edit a parent, all related children, and all related grandchildren via a single “flattened” interface.

2019-04-24_16-22-61

Demo file: magic-portals.zip (requires FM 16 or later) Continue reading “Magic Portals”

ExecuteSQL, Level: Intermediate, SQL, Virtual List

Bill of Materials

29 Mar 2019: Demo file has been updated to v2. See comments for details.

Editor’s note: Geoff Gerhard of Creative Solutions is one of those “quiet” developers who has been helpfully sharing his knowledge in online FileMaker forums for more than 20 years. I personally have benefited enormously from his expertise, and am pleased to feature his first appearance as a guest author here on FileMaker Hacks.

Demo file: BillOfMaterialsDemo-v2.zip

Continue reading “Bill of Materials”

Level: Intermediate, Version: FM 12 or later

Disabling New Window

Today I want to talk about a potential problem lurking in a small percentage of FileMaker solutions, and discuss various options for mitigating it.

As you may know, there are three ways to display a new window…

  1. Via the New Window script step
  2. Via the Go To Related Record script step
  3. Manually via Window > New Window

…and it’s this last option that can, depending on circumstances, be problematical.

2019-02-23_13-06-51.png

I say “depending on circumstances” because typically it’s okay for a user to spawn a new window, which is to say that doing so doesn’t pose any challenges beyond those the developer already faces when building a multi-user system, which presumably the developer has considered and has intelligently dealt with.

Continue reading “Disabling New Window”

FM Development, JSON, Level: Intermediate, Version: FM 16 or later

Creating and Using Invisible Window IDs

Editor’s note: I first became aware of Paul Jansen when I licensed his FMTools in the late 1990s, and I finally had the pleasure of meeting him last June at dotFMP after 20 years of online and voice communication. It’s an honor and a privilege to welcome him to FileMaker Hacks as a guest author.

FileMaker is pretty flexible. As developers we are given options as to how to reference things; fields, scripts and layouts can be referenced by name or number/id. Whilst we know that referencing things by name is more fragile, it is still a very useful capability to have, but it is definitely more robust to reference by ID…

Windows are a bit of an odd one out; we can only reference them by name.

As windows are probably the most likely things to have their names changed during normal day to day usage of a FileMaker Database it would be really useful if we could keep track of them by an ID independent of the displayed window title. Another benefit of having access to an ID to identify a window is that we then have to option to very easily store and access window specific variables. Kevin has made use of window specific variables based upon the window name in several articles and I suggest that access to a numeric ID that was independent of the window title would be an improvement. Continue reading “Creating and Using Invisible Window IDs”

Level: Intermediate

Tips ’n’ Tricks, part 3

It’s been a few years since we last had a tips ‘n’ tricks article here at FileMaker Hacks, and during the interim some new items have accumulated in the old developer bag of tricks. (If you like this sort of thing, you may also want to check out part 1 and part 2.) Some of these are obscure, and one is very basic. Ideally developers at all levels of expertise will find something useful (or worth arguing about) in what follows.

I recall Corn Walker introducing a DevCon session by saying, “I’m just a kid who paid attention in math class.” Along similar lines I pay attention when smart people share their hard-won wisdom, and a number of the following tips come from these individuals with (what I hope is) proper attribution.

Tip #1: One of these functions is not like the others

Some FileMaker functions require one or more arguments, e.g., Sum () or Evaluate ()… some do not require an argument, e.g., Random… and there is a single function where the argument is optional, i.e., the function can stand alone without parentheses like so…

Function

…or with parentheses like so:

Function ( argument )

Do you know which one it is? (See further discussion at the end of this article.) Continue reading “Tips ’n’ Tricks, part 3”

Level: Intermediate, Version: FM 16 or later

Faux Subsummaries with Variable Height Rows

Recently we’ve looked at two methods to generate a “faux” subsummary to address a shortcoming of FileMaker native subsummaries… namely that in a multipage report you can have orphaned entries at the top of a given page with no indication of what parent entity they belong to.

2018-12-03_114620

The methods were documented here:

One limitation of both the above approaches is that they only worked with fixed-height report rows. Well today we have a nice, outside the box solution from Daniel Wood that does not suffer from this limitation.

Demo file: Faux-Subsummaries-with-Variable-Height-Rows.zip (requires FM 16 or later) Continue reading “Faux Subsummaries with Variable Height Rows”