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 the host is upgraded.

File Options

There is a setting in File Options called "Minimum version allowed to open this file:". The version number must be of the form M.m, where M is the major and m is the minor version number. For example, to prevent versions earlier than 26 from opening the file, enter 26.0.

When this is used and the client version is lower than the value set, there is a standard FileMaker error dialog on opening the file. This message includes the minimum version number required and an OK button. The user has no option to open the file. The message cannot be customised.

A more flexible option

We can do better than the above with some custom scripting in the OnFirstWindowOpen script.

The first thing we need to do is to detect the client version being used. And there's a function for that – Get ( ApplicationVersion ). Examples of what is returned include:

  • for FileMaker Pro – "Pro 26.0.1"
  • for FileMaker Go on iPhone – "Go 26.0.1.40"
  • for FileMaker WebDirect – "Web Publishing Engine 21.1.6"

If we wrap this result inside a GetAsNumber function, this will return the decimal version. For example, in the above examples, FileMaker Go returns 26.014. Like the File Option, we are really only interested in M.m so the full expression will be:


Truncate ( GetAsNumber ( Get ( ApplicationVersion ) ) ; 1 )

The next step is to add some script steps at the start of the OnFirstWindowOpen script.

We need to decide which clients we are going to detect. It may not be necessary to take any action for FileMaker Server, Data API, OData and ODBC clients. With that in mind we can add the following script steps:


Set Variable [ $minimumClientVersion ; Value: 22.1 ]
Set Variable [ $clientVersionNumber ; 
  Value: Truncate ( GetAsNumber ( 
         Get ( ApplicationVersion ) ) ; 1 ) ]
Set Variable [ $clientTypeShort ; 
  Value: LeftWords ( Get (ApplicationVersion) ; 1) ]
Set Variable [ $clientTypeLong ; 
  Value: 
  Let ([ type = $clientTypeShort]; 
       Case (  type = "Pro"; "FileMaker Pro"; 
               type = "Go"; "FileMaker Go"; 
               type = "Web"; "FileMaker WebDirect"; 
               "Unknown" )) ]
If [ PatternCount ( "ProGoWeb" ; $clientTypeShort ) 
     and 
     $clientVersionNumber < $minimumClientVersion ]
  Show Custom Dialog [ "Version not supported." ; 
                       --custom message here-- ; OK]
  Close Window [ Current Window ]
Else
  # no action required
End If

The flexibility here is that we can completely control the messaging and the subsequent action.

The custom dialog message might be something like:


"You are using an unsupported version of " 
& $clientTypeLong & ". ¶Your version is " 
& $clientVersionNumber 
& ". ¶The minimum version required is " 
& $minimumClientVersion 
& ". ¶Please seek assistance to upgrade.
¶The database will now close."

which would produce a message like:

You are using an unsupported version of FileMaker Pro.
Your version is 19.6.
The minimum version required is 22.1.
Please seek assistance to upgrade.
The database will now close.

Instead of simply closing the window (which will close the database), you could use Exit Application. However this is annoying if the user already has a number of FileMaker files open.

Multi-version solutions

If it is absolutely necessary to allow a range of client versions, then you can use the same functions to account for this in your scripts.

Let's consider the case where you allow clients to use either version 22 or 26. If a script uses a FileMaker 26 feature then you may need to modify the script with an If statement.


If [ Truncate ( GetAsNumber ( 
     Get ( ApplicationVersion ) ) ; 1 ) < 26 ]
  # run the v22 compatible processes 
    or do nothing or display dialog
Else
  # run the v26 script
End If

Persistent data

With the new persistent data feature in FileMaker Pro 26, it may be useful to add to opening scripts such that the version information is stored in persistent data. This can then be accessed in a customised format at any stage in the session.

As per advice above, this may need to be wrapped in a test for the current version being used. However, it might be best practise that if you are using persistent data at all, then the minimum version should be 26.

The persistent data may be stored as entries per account name in JSON format:


Set Variable [ $clientJSON ; Value:  
  JSONSetElement ( "" ;  
    ["name"; $clientTypeLong; JSONString ]; 
    ["version"; $clientVersionNumber; JSONNumber ] 
  ) ]
Configure Persistent Data [ 
  Account ; 
  Instance ID: Get ( AccountName ) ; 
  Value: $clientJSON ]

The persistent data entry can be extracted as a JSON object and then parsed for messaging or version testing:


Let ([ 
  data = GetPersistentData ( "account" ; 
            Get ( AccountName ) ); 
  name = JSONGetElement ( data ; "name" ); 
  version = JSONGetElement ( data ; "version" )
]; 
"Client version in use: " & name & " " & version & "."
)

There are a number of other pieces of data that may be useful to store in a persistent data entry for the account. This is a new area and all the use cases are still being discovered.


Are you coming to Reconnect.Christchurch, 15-16 October?
Get all the details and purchase tickets at Reconnect.Christchurch.

Are you late to the ScriptLogic party? If you have missed out on some of these emails, catch up here: Email Archive

If you know someone else who you think might like this email, you can send them this link to subscribe: Subscribe to ScriptLogic Daily