The A-Z of FileMaker: H is for Host

H is for host

With the FileMaker Platform, you can share data in a file over a network. Many users can access the same data set at the same time.  The shared file is open on a host device and available on the network. In the FileMaker world, the host is a computer (rather than a mobile device), but it may be a physical or virtual computer.

Another name for a host like this is a ‘server’. All servers are hosts, but not all hosts are servers. Only hosts that accept connections from other devices (clients) qualify as servers.

How to host a file

There are two FileMaker products that can host a FileMaker file – FileMaker Pro and FileMaker Server. You should consider FileMaker Pro as a host only for testing or for a limited timeframe. FileMaker Server is a robust and performant host recommended for all long term hosting.

FileMaker Pro as host

Hosting a file with FileMaker Pro is quite simple. Open the file and choose File > Sharing > Share with FileMaker Clients…. In the FileMaker Network Settings, turn Network Sharing on. Then choose a currently open file from the list and set network access to All users.

FileMaker Network Settings for host

FileMaker Pro is a limited host – it can accommodate up to five connected clients. Those clients can be either FileMaker Pro or FileMaker Go (no web clients). If the host needs to close the file for any reason, all clients must exit.

FileMaker Server as host

Install FileMaker Server software on a dedicated server machine. It is beyond the scope of this blog article to consider all the requirements for the server configuration. When the FileMaker Server has been installed and configured properly, upload files to the server from FileMaker Pro.

Open the file and choose File > Sharing > Upload to FileMaker Server…. In the resulting dialog, choose the FileMaker Server on the network and supply server admin credentials.

Did you know?

FileMaker Server can host up to 125 files simultaneously and easily accommodate 100 concurrent clients accessing this files.

Connecting to a hosted file

When you use FileMaker Pro, you can open a file stored on your local device as a single user. By definition, a hosted file is available on the network. To connect to a hosted file with FileMaker Pro, you choose File > Open Remote…, then choose a host and a file.

As with local files, you may need to provide account credentials to open the file. You are strongly advised to ensure that all hosted files are password protected. This will stop casual networkers having a look at the file. And obviously, you should use strong passwords.

Did you know?

Network traffic travels in and out of devices through numbered ports. The standard port for web traffic between your browser and the web server is port 80. Standard FileMaker traffic uses port 5003. When you are using FileMaker Server with SSL enabled, it also uses the standard SSL port 443.

Why use FileMaker Server as a host?

FileMaker Server provides many more important hosting features than does FileMaker Pro.

  • Scalability and Performance
  • Security – SSL connection, host AES-256 encrypted files, logging
  • Sharing – WebDirect and custom web publishing (PHP), OBDC/JDBC support
  • Maintenance – scheduled backups and procedures, web management console

For more details, refer to the FileMaker web page for FileMaker Server.

The A-Z of FileMaker: G is for Get

G is for Get (functions)

The FileMaker calculation engine provides almost 300 built-in functions. Plug-ins and custom functions provide even more. The largest group of built-in functions is the Get group. FileMaker Pro 15  includes 116 Get functions and more are added each version. In the calculation engine, you can type “get” and press the return key to see all the Get functions:

Get functions

Inline help shows what each function will return.

The basic structure of a Get function is:

Get ( InformationName )

where the InformationName is the information returned by the function. Get functions do not have any parameters – they query the system and return information.

When was that?

Perhaps the most commonly used Get function is the one that returns today’s date:

Get ( CurrentDate )

The “current” date is provided by the machine where the calculation is evaluated  – that may be a desktop client, mobile device or server. To be consistent in the date used for a hosted solution, it may be better to use:

Get ( CurrentHostTimestamp )

While this will return both the date and time from the host, it can be explicitly coerced to the date:

GetAsDate ( Get ( CurrentHostTimestamp ) )

Alternatively, if the calculation returns a date result or is inserted in a date type field, then FileMaker will coerce the date for you.

Note

The GetAsDate function used above is not classified as a Get function. There are 9 GetAsType functions that coerce data to a specific data type. There are 14 other functions that also start with Get such as GetNthRecord and GetLayoutObjectAttribute.

Did you know?

The Get ( CurrentDate ) function has been known by different names in previous versions of FileMaker Pro. Most recently, it was Status (Current Date) and before that it was Today.

Other Get functions that return date and/or time are:

  • CurrentTime
  • CurrentTimestamp
  • CurrentTimeUTCMilliseconds
Timing of evaluation

As with all calculations, you should know when the expression will be evaluated and re-evaluated if necessary.

When using the Get ( CurrentDate ) function, a developer will usually expect it to be using the current date. For example, this is a calculation for the ageing of invoices that returns the number of days since the invoice was issued:

If ( InvoiceDate < Get ( CurrentDate ) ; 
     Get ( CurrentDate ) - InvoiceDate ; 
     0 )

If the calculation field is set up with default storage (stored result), the expression will be evaluated when the invoice date is entered or modified. However, if the solution is closed and re-opened the next day, the expression will not be re-evaluated using the new current date. For an invoice issued on a particular date, the age of the invoice may stay at zero (0) days forever.

To ensure that the expression is re-evaluated as needed. the developer should set the calculation storage to unstored by checking the option for “Do not store calculation results — recalculate when needed”:

calculation storage options
Set Storage Options… in the calculation dialog box
Querying security

There are a number of Get functions that return information about the current security level of the user. These include the account name, privilege set name and list of extended privileges. You can use these functions to control scripted operations while using proper FileMaker security setup.

Extended privileges are great for assigning privileges to multiple privilege sets. For example, in a medical system, a custom extended privilege to allow prescribing of drugs may be assigned to a number of privilege sets (chief MO, doctor, head nurse, psychiatrist) but not to others (nurse, administrator).

The function Get ( AccountExtendedPrivileges ) returns a list of enabled extended privileges for the logged in account privilege set. The following expression will check for the existence of the extended privilege canPrescribe in that list:

Length (
  FilterValues ( Get ( AccountExtendedPrivileges ) ; 
                                     "canPrescribe" )
       ) > 0

The expression can be used in an If or Else If script step to approve the running of the script steps that follow. Using a custom extended privilege in this way allows for quick and simple assignment (or revocation) of privileges to multiple privilege sets.

Query the device and network

Some Get functions provide information about the device and the network being used:

  • Device
  • HostIPAddress and HostName
  • NetworkProtocol and NetworkType
  • ConnectionAttributes and ConnectionState
  • PersistentID, SystemIPAddress and SystemNICAddress

You can identify and log devices and clients with these functions, as well as checking that the network is appropriate for connection.

Other Get functions check the client and host software:

  • ApplicationVersion, HostApplicationVersion, SystemVersion
Query the state of the solution

A number of Get functions allow the developer to check what is going on in the solution and act appropriately.

  • FoundCount, RecordNumber
  • RecordOpenState
  • LayoutName
  • WindowInfo (there are 14 of these such as WindowName)

For example, Get (FoundCount) is commonly used in scripting to determine what to do next. Different actions may be appropriate depending on if there are zero, one or many records found.

If a developer uses a consistent layout naming convention, Get ( LayoutName ) can be used to determine the context and the next action. In a script:

If [ PatternCount ( Get ( LayoutName ) ; "customer" ) ]
     # do this for customers
Else If [PatternCount ( Get ( LayoutName ) ; "invoice" ) ]
     # do this for invoices
Set a primary key

It is common to use a universally unique identifier (UUID) as a primary key value rather than a serial number. This is made easy by the use of the Get (UUID) function. This returns a unique 16-byte string such as:

35D390F0-3602-4CE0-8014-F4990A845934
Developer Tip

When creating a primary key field, use the Get (UUID) function in an auto-enter calculation. Remember to turn OFF “Do not replace existing value of field (if any)” to prevent duplicate UUIDs.

Set and get file locations

Get functions can be used to set storage locations for files when sending to PDF or exporting records, and for retrieving files for email attachment and other processes.

  • DesktopPath, DocumentsPath, TemporaryPath
  • FilePath, FileMakerPath, PreferencesPath

For example, a developer could define the path and file name for a PDF file as:

Get ( TemporaryPath ) & 
Cust::custCode & "_" & Invoice::invNo & ".PDF"

If the developer sets this to a variable, that variable can be used for defining the file attachment in a following Send Mail script step. Since the PDF is saved in the temporary path location, it is cleaned out at the end of the session.

And so much more…

As stated above, there are over 100 Get functions. Clearly there is not room in one blog post to cover even half of them.

As a FileMaker developer, you would be wise to spend time familiarising yourself with many of them including understanding exactly what each returns in what circumstances. Get functions will often return variable results based on where they are evaluated (FileMaker Pro, FileMaker Server, FileMaker Go, FileMaker WebDirect).

Did you know?

uLearnIT runs FileMaker classes. You will learn about Calculation and Summary Fields in the Get Started with FileMaker Pro 15 course.  Learn more about FileMaker classes.

The A-Z of FileMaker: F

F is for find the found set

One of the advantages of using a database rather than a spreadsheet is the innate ability to find data. Sure, with a spreadsheet you can apply filters but it is not really the ‘wheelhouse’ of a spreadsheet.

When using FileMaker Pro, the status area shows how many records are in the table you are viewing on the current layout. In the top screenshot below, the current table has 102 records in total (and the current record is #98).

find results in found set
All records (102 total) and found set (62/102)

After a find request has been performed, there are 62 records in the found set. When you show all records, the found set is the entire table.

Why is the found set important?

Many operations in FileMaker apply to the found set of records (and therefore not to the ‘unfound set’). The following will apply only to the found set:

Replace Field Contents
Delete Found Records
Export Records
Constrain Found Set
Sort Records
Save Records as PDF or Excel
Print

It is commonplace to find a set of records before performing these operations. For example, if you wanted to print a daily invoicing report, you would first find invoice records from the day, then sort and print the found set.

Records not in the found set are effectively excluded or protected from bulk operations.

How is a found set managed?

As shown above, the most common way you will create a found set of records is to perform a find.
Continue reading “The A-Z of FileMaker: F”

Mentoring services – getting the help when you need it

You probably know that uLearnIT offers hands-on FileMaker classes. These are the ideal way to get quickly up to speed with everything you need to know about FileMaker at a specific level. The classes give you the chance to ask questions and get help on your individual projects. But there is a lot of content to cover in two days.

So what do you do when you leave the class and it is just you, sitting at your desk, trying to get something to work? Google it! Three hours and some funny cat videos later you are still not any closer to a solution.

You need a mentor. Someone who can jump in and look at what you want to achieve, what you have been doing and where you are stuck. This sort of on-demand help is ideal for those who know what they want to do but have just hit a small brick wall in achieving it.

uLearnIT offers FileMaker mentoring services to give you a literal “hand up” on your solution. Read more about how it works and how to get started at our FileMaker Mentoring page. It may be the best investment you can make in your own FileMaker development.

 

The A–Z of FileMaker: E

E is for encryption

Encryption is the act of encoding data so that it cannot be understood by normal means. To be understood, it needs to be decrypted, and that can only be done by authorised parties.

Did you know?

Cryptography is “hidden or secret writing”; steganography is “covered or concealed writing”. The difference is privacy versus secrecy. Both date back to the classical Greeks with Spartans using the scytale transposition cipher, and Herodotus reported using tattooed messages on a slave’s head hidden by regrown hair.

Clearly, encryption is done to protect data and is often an important part of a security strategy. In the FileMaker Platform, there are many areas where data is encrypted – some of these are optional, others are the standard.

Challenge

Before reading any further, how many areas of FileMaker products can you name that use encryption? Consider all products in the FileMaker Platform.

Encrypted passwords

When you create a FileMaker security account, you specify an account name, password and select a privilege set. The password is encrypted and stored in the file. The encryption method used is a one-way hash, meaning that the stored encrypted password can never be decrypted.

So how does FileMaker Pro check that your password is correct when you log in?

The password you enter is encrypted by the FileMaker client using the same hash used when storing the account password. The your encrypted password is compared with the stored encrypted password, and if they match you are allowed access.

A one-way hash is also used for the FileMaker Server Admin Console password.

Did you know?

Before FileMaker Pro 7, passwords were stored in plain text. Hacking utilities existed that could easily extract passwords from files.

Database (file) encryption

Data stored in a standard FileMaker file is encoded but not encrypted. This means that if you can decode the file, the data is there in plain text. You do not need a password. Of course, you do need access to a physical copy of the file. Maybe you ‘found’ an old backup copy stored on a drive?

Starting with FileMaker 13, database files can be encrypted. This is referred to by FileMaker as Encryption at Rest ( EAR). Using the Developer Utilities in FileMaker Pro Advanced, a file or files can be selected and the option applied to Enable Database Encryption. To do this, you must supply a Shared ID, Full Access account name and password, and an Encryption Password.

The Shared ID is used to link multiple files in a solution.

It is strongly advised that the Encryption Password be complex, and as with other passwords, it is case sensitive. Write it down and store it securely! If you ever lose the Encryption Password for your file, no-one will never be able to access the file again (not even FileMaker Inc.).

When a file is encrypted, the user must enter the Encryption Password to open the file before entering their account credentials. The exception to this is when the file is hosted by FileMaker Server – the server can be authorised to host the file and store the Encryption Password so that users only need their account credentials to access the file. Importantly, closed files or backup copies made by the server are encrypted at rest. So the contents are secure even if someone can access a backup copy.

FileMaker uses AES-256 in CBC mode for file encryption. This is the encryption level required at the highest levels of government for top-secret data.

SSL for network communications

Data transferred from FileMaker Server to a FileMaker client over a network is not secured by default. It is possible to collect and decode packets of data sent. FileMaker Server allows the configuration of SSL with a custom certificate.

Did you know?

The standard FileMaker SSL certificate installed by default on FileMaker Server is intended for test purposes only. A custom SSL certificate is required for production use.

Enabling SSL on FileMaker Server will encrypt network traffic between FileMaker Server and:

  • FileMaker clients – FileMaker Pro, FileMaker Go, FileMaker WebDirect
  • remote Server Admin Console sessions

It will also encrypt:

  • files uploaded from FileMaker Pro to FileMaker Server
  • progressive download of interactive container data

It will not encrypt data between FileMaker Server and ODBC sources – this requires SSL configuration on the ODBC source. The same applies for communications withActive Directory or Open Directory for user authentication.

Did you know?

If you use FileMaker Pro as a host (for up to five guest clients), you cannot secure network communications between host and client.

Email notifications and directory services for FileMaker Server can also use SSL to encrypt communications.

Secure container storage

When you specify external storage for a container field, there is an option for secure storage. When this is selected, container data is stored in an obscured folder structure outside of the database file and each document is encrypted.

A typical secure storage folder structure is shown below. There are encrypted files named 2E85 and 112C. The file path is a UUID broken into parts.

The encryption method used for secure container storage depends on whether the file itself is encrypted. For encrypted files, secure container storage uses AES-256 in CBC mode; standard files use AES-128 in CBC mode.

The encryption key is held in the FileMaker file and is needed to decrypt the stored files. Without the FileMaker file, the stored files are not accessible.

FileMaker Go

FileMaker files stored on an iPad or iPhone device in FileMaker Go will be encrypted using the Apple iOS encryption as long as the device is passcode protected. There is nothing required to implement this encryption and the user does not require any encryption keys to access the files. This means that local files on a device are secure if the device is lost or stolen – the passcode is required to copy the files from the device.

Challenge Answer

Five – passwords, files, network traffic, container data and FileMaker Go files. Did you get all these encryption areas before you started reading? Are there any we have missed?

Did you know?

The author, David Head, has presented several FileMaker Security sessions at the annual FileMaker Developer Conference. Last year in Las Vegas, he presented a session titled Cryptography, SSL & the FileMaker Platform.

Can your business be more efficient?

It’s really a rhetorical question. All businesses can be more efficient. The trick is finding the best areas to improve – those that will bring the greatest benefits for the least effort.

If you could spend an hour modifying a process that saved you two hours every week, that is a raw return on investment (ROI) of 200% just in the next week. That would be incredible. However, it is probably more likely that you will spend more time on something that will save less time each week. Nevertheless, the ROI over the coming months will certainly add up.

So where do you start?

Review

First, you need to know where you are now. What is it that takes up the time in your day? What is it that you spend money on? What is it that sometimes requires fixing or redoing because it is not done right?

Select

Once you know where you are, choose one or two areas to work on. Look at potential inefficiencies. Consider any and all possible solutions. Look for the low hanging fruit — things that look like an easy fix for an immediate return. The key when you start is not to pick a six month project. There must be something that can be improved next week. It just needs to be done.

Quantify

Try to quantify the inefficiencies in terms of time, money and effort so that you can then set goals for improvement. These will be the factors that you measure as you implement changes.

Execute

Set up a clear plan for executing the improvements. As you execute, measure your processes and compare them with where you were. Don’t be surprised if efficiency goes down before improving – that often happens when new processes are introduced.

Repeat

When you have successfully implemented a change to a process and quantified the gains, look for other areas in your business where similar changes can be applied. In this way, you are leveraging off your success.

Do you want help?

uLearnIT can help you with your business processes. Contact us now to have a chat about where you would like to start improving your business processes.

The A–Z of FileMaker: D

D is for dialog

A dialogue (or dialog) is a conversation, talk, discussion or chat.

In computer terms, a dialog box (or simply, dialog) is a small window that communicates with the user, giving them options (via buttons) or allowing responses (as text).

Here is an example of a dialog seen in macOS when you empty the Trash via the Finder menu:

Dialogs are often classified as modal or non-modal. A modal dialog will block any further action in the application until the dialog is dealt with.

Did you know?

Menu commands that end with an ellipsis (…) will proceed to a dialog; those that do not, immediately execute the command. For example, in FileMaker Pro, the Records menu has a number of commands followed by an ellipsis including the destructive Delete Record… and Delete Found/All Records… commands!

Native FileMaker Dialogs

When using FileMaker Pro, any user will see a range of native dialogs – those that are generated by the application rather than by a developer. These dialogs are built into processes such as record sorting, importing and printing.

As mentioned above, one type of dialog is that seen after choosing a menu command (or using the shortcut). Where the command is destructive, the default option is to cancel.

Another sort of dialog is an error as a result of a process the user runs. For example, if the user performs a find and no records are found, the user can cancel the process or try again by modifying the find request.

Some FileMaker dialogs are more complex, allowing the user to make a number of choices before proceeding. One example is the Sort dialog, which may be a simple ascending sort by one field, or a complex multi-level sort using a summary field to re-order groups:

Native dialogs may also be displayed when validation field options are set and a validation rule is broken. For example, if a field has validation to require it to be “Not empty”, leaving the field blank may result in the following dialog when the record is committed:

Native FileMaker dialogs cannot be customised by the developer. Sometimes, they are not intuitive for all users – they may communicate the wrong message, be difficult for the user to understand, or provide unnecessary options.

Custom Scripted Dialogs

The majority of custom dialogs in FileMaker solutions are created with the Show Custom Dialog script step. This allows the developer to craft a message and to provide up to three buttons for the user. The button clicked by the user can be queried with the Get ( LastMessageChoice ) function and conditional actions performed as a result.

The custom dialog also allows for up to three text input fields. This allows the user to enter data into fields through the dialog. The input fields are specified and can be labelled in the dialog  by the developer. There is an option to use the password character (•) to obscure input.

Did you know?

The result of the button choice for a custom dialog will persist in a script until another custom dialog is presented or until the script ends. This means that the Get ( LastMessageChoice ) function does not need to be invoked immediately after a dialog.

Changing the Message

If the developer is not confident that the user will understand the native validation message shown when a rule is broken, they may craft a clearer message.

For example, a rating field may have validation set that it must contain a value that is a member of a value list. If that list contains the numbers 1, 2, 3, 4 and 5 and a user enters 2.5 or 6 in the field, they may see the following validation dialog:

It is not clear to the user what is a ‘valid’ value. And they may not understand what the Revert Field option will do. So the developer may opt for a custom message:

Did you know?

When crafting a custom error message, it is important to do two things – let the user know what went wrong, and give them options to fix it.

Suppressing FileMaker Dialogs

A FileMaker developer can suppress most of the native FileMaker dialogs that arise, and they can provide their own dialog for the user.

In scripting, the Set Error Capture [On] script step will suppress native FileMaker error dialogs. This does not mean that the error does not happen – simply that the dialog is not shown. This is useful when the error needs to be handled in a particular way.

One commonly captured error is that where no records are found. In many scripts, the Find process is built in and not actually performed by the user. So a message stating that no records were found would be confusing.

In that case, the developer can use script steps to test how many records were found and then act conditionally on the result. For example, it may be reasonable that if no records were found that a new record is created. This could be done without involving the user, or they could be shown a dialog stating what happened and giving them the option to create a new record.

Did you know?

The Get ( LastError ) function is used to retrieve FileMaker error codes. A commonly trapped error is 401, meaning “No records match the request”. When no error occurs, the error code is 0.

Many script steps provide the option to suppress the dialog. This is often used when the action should be automatic and the user would not necessarily know what settings to apply. Examples of script steps where the dialog might be off are Sort, Print Setup and Export Records. In these cases, required settings would be stored for each step. The Print step will usually present a dialog.

When you need to inform your user or get information from your user, dialogs are the way to go.

The A–Z of FileMaker: C

C is for container

Container is a field type.

When you build a database, most of your fields will likely be text fields. Other standard data field types are number, date, time and timestamp. Although each of these have subtleties in how they store and present data, they are fairly obvious in their usage.

Why use container fields?

Container fields exist to store files such as a picture, a video or a PDF file. Such files are often referred to as binary files (as opposed to text files). Although some of their contents may be read as text, the file usually requires interpretation to ‘read’ the contents.

As opposed to storing data such as a text string or a number, container fields allow us to store documents or files. This can be extremely useful in creating a store of files that can be searched and accessed within a database structure. Many people will find use for a document management solution that stores PDF copies of files.

Inserting

There are a few different ways you can use to get a file into a container field and container fields have additional native functionality on iOS devices.

On the desktop, you can insert a picture into a container by:

  • drag and drop
  • Insert > Picture…
  • Insert > File…

Either of the first two methods will display the picture in the container field; the last method will display only the file icon and name. Your choice will depend on your intended use of the file – most users will be storing pictures for viewing while using the database.

On iPhone and iPad devices, you can insert images directly from the camera or from the Photo Library. Container fields also allow you to scan and capture a bar code with the camera, or to capture a signature as an image using sign-on-glass.

PDF files can be stored and displayed such that they are interactive – you can scroll through a multi-page PDF in a container field and use tools to zoom and print. To do this, the PDF must be drag-dropped into the container )or use Insert > PDF…), and the container must be formatted on the layout to be interactive (see later section on Formatting).

Storage

By default, files are copied into a container field and stored in the database file itself. This has two implications:

  • the original file can be moved, edited, renamed or deleted without affecting the stored copy
  • the database file will get larger, by approximately the size of the file inserted

When using the Insert menu to insert a picture, file, media or PDF, there is an option in the dialog to “Store only a reference to the file”. If you check this option, FileMaker will create a link to the original file in the container field. This will keep the database file size smaller. The link is used when the container field is displayed. If the file linked is missing, an error is shown in the container field – “The file cannot be found: <file name>”. This could happen if the file was moved or renamed.

Container fields have special field options under Storage.

You can change the option to store container data externally. This means that all files are stored outside of the database file in a folder structure created and managed by the FileMaker client. The folder structure is usually next to the database file in the computer filing system (there are special locations on FileMaker Server for hosted files).

For external storage, there is a further option for secure storage  or open storage. Secure storage creates a complex filing structure based on UUIDs and also encrypts the files. Files can only be decrypted by the FileMaker client and the FileMaker database. Open storage creates a logical filing structure of file/table/field with the raw files inside.

If any externally stored file is altered, the container file will display an error that the file has been tampered with (see above image). This is a security feature.

Formatting

Container fields on a layout can be formatted through Data Formatting on the Data tab of the Inspector (see below). These formatting options affect the size of the image displayed, alignment in the container, and whether the container field instance is interactive (important for PDF display and video playback).

Export

If the user has access to the field, they can export the contents of a container field using Edit > Export Field Contents….

Calculations

There are some calculations which are useful when looking at container field contents. Calculations can be used to get information about the file in a container field.

GetContainerAttribute ( Table::Container; "all" )

returns a return-separated list of a lot of useful attributes of an image such as file name, storage type and file size. The attributes are grouped into categories and have name pairs. Use parsing techniques to extract any attribute data you need. An example of what is returned is shown here:

[General] 
Filename: chart-1.png 
Storage Type: File Reference 
MD5: 00AE673591301E56D2EDFDFC53D21280 
File Size: 2355 
Internal Size: 74 
External Size: 2355 
External Files: 1

You can also query a single attribute, so:

GetContainerAttribute ( Table::Container; "filename" )

will return just the named attribute. The file name can also be extracted using:

GetAsText ( Table::Container )

Where the file is stored as a reference, the above expression will return the file name and the stored file path as a return separated list. For example:

file:landscape.png
filemac:/Macintosh HD/Users/johndoe/Desktop/landscape.png

Another GetContainerAttribute is filesize, the file size in bytes, which can also be returned using:

Length ( Table::Container)

For photos, you can access metadata if it is stored in the file. This may include latitude and longitude of the photo location, and make and model of the camera.

For signatures captured on an iOS device, use the signed attribute to get the timestamp when the signature was inserted.

The GetThumbnail function is very useful to return a down sampled version of an image stored in a container field (calculation result is container). The function format is:

GetThumbnail ( sourceField ; fitToWidth ; fitToHeight )

This example will return an image one third the size of the original:

GetThumbnail ( picField ; 
               GetWidth ( picField ) / 3 ; 
               GetHeight ( picField ) / 3 )
Want to know more?

uLearnIT runs FileMaker training classes in Australia and New Zealand. See the FileMaker Training page for more details.

The A–Z of FileMaker: B

B is for Boolean

A Boolean value is either true or false.

A Boolean expression is one that produces a Boolean value when evaluated.

FileMaker Pro uses Boolean expressions in a number of areas – calculations, scripts and object formatting to name a few. When creating an expression to be evaluated by the FileMaker calculation engine, you may use functions that either use or return a Boolean result.

If function

The If function has the format:

If ( test ; result1 ; result2 )

The test is a Boolean expression. If it evaluates to true then result1 is returned, otherwise result2 is returned.

If ( Year (dateBirth) >= 1995; "Gen Z"; "Other")

The above example of an If expression will return the string “Gen Z” if the year of the date of birth for the record is greater than or equal to 1995; in all other cases, it will return the string “Other”.

Note that the FileMaker calculation engine also allows numeric results for the test where 0 (zero) is false and any non-zero numeric result is true.

DID YOU KNOW?

FileMaker provides the Case function for evaluating a series of tests.

If script step

The If script step has the structure:

If [ test ]

   # do script steps here if the test is true

Else

   # do script steps here if the test is false

End If

As for the If function, the test in the If script step should return a Boolean or a numeric result. If the test returns no data (null) or does not resolve into a number, then it evaluates to false.

IsEmpty

The IsEmpty function has the format:

IsEmpty ( field )

It is a Boolean function returning 1 (true) if the specified field is empty; otherwise it returns 0 (false).

In addition to specifying a field name, you could also provide a text or numeric expression for evaluation.

Boolean Operators

The FileMaker calculation engine provides Boolean operators (and, or, xor, not) to construct more complex logic in expressions.

For example, the test in a If function:

If ( isEmpty ( discount ) and salescount > 10; 0.1 ; 0 )

For the test to return a true result (and therefore the function to return 0.1), both the expressions (separated by the and operator) must be true.

Other areas of use

You can also find Boolean expressions in:

  • other functions – e.g. Case, Choose
  • other script steps – e.g. Exit Loop If
  • conditional formatting and visibility of layout objects
  • security – record level access controlling view, edit and delete
  • custom menus – conditional installation
Did you know?

FileMaker reserves the words true and false. Each of these returns what it says. So what would the following inane expression return? This or That?

If ( true and not false ; "This" ; "That" )

The A–Z of FileMaker: A

A is for Auto-Enter

When using a data field (text, number, date, etc.), you can set field options. The first set of these are for auto-entry of values in the field. In most cases, the auto-entered data will be entered in the field when a new record is created. In some cases, the data can be updated when the record is modified.

Although the interface uses checkboxes for the choices, these are mostly exclusive (you can only choose one). And that makes sense.

Challenge: Find the non-exclusive choice and investigate how that behaves when two separate auto-entry options are set.

Creation

Data is set when the record is created. Choose from date, time, timestamp, name or account name (depending on field type).

The date and time are from the client’s clock. Name is the user name from the client’s preferences. Account name is the currently logged in account.

Modification

The data will be set when the record is created and updated each time data in the record is modified and committed. Choose content as for creation.

Serial Number

Sets a incremental serial number when the record is either created or committed. The next value is specified and an increment set (usually 1).

The last numeric ‘word’ of the next value is incremented. For example, for an increment of 1:

  • 1999 increments to 2000
  • A001999Z increments to A002000Z
  • A001-999Z increments to A001-1000Z
  • 100.9 increments to 100.10
Value from last visited record

Enters the data from the same field from the last record where any field was entered (but data not necessarily changed).

Data

A defined data string up to 255 characters. Often used to set a default value for a field for new records e.g. set the Status field to Draft for new projects. If a conditional string is required, use a Calculated value (below).

Calculated value

A value returned by evaluating a calculation expression at the time of record creation. When the option for “Do not replace existing value (if any)” is unchecked, the expression may be re-evaluated.

Looked-up value

A value looked up from another related table and copied into the field. This option has largely been superseded by the more flexible Calculated value (above). However, it does provide the additional option of copying the next smaller or larger value if there is no exact match.

Prohibit modification during data entry

If checked, will prevent a user from modifying any value in a field by keyboard entry. The auto-entered value could still be modified by a script step or when the record is modified.