Learn FileMaker Pro 16 The Comprehensive Guide To Building Custom Databases
Learn FileMaker Pro 16 The Comprehensive Guide To Building Custom Databases
FileMaker Pro 16
The Comprehensive Guide to Building
Custom Databases
—
Mark Conway Munro
Learn FileMaker Pro 16
The Comprehensive Guide to Building
Custom Databases
■
■Part I: Using FileMaker����������������������������������������������������������������������� 1
■
■Chapter 1: Introducing FileMaker�������������������������������������������������������������������������� 3
■
■Chapter 2: Exploring the Application������������������������������������������������������������������� 19
■
■Chapter 3: Exploring a Database Window����������������������������������������������������������� 45
■
■Chapter 4: Working with Records������������������������������������������������������������������������ 61
■
■Chapter 5: Transferring Data������������������������������������������������������������������������������� 99
■
■Part II: Defining Data Structures����������������������������������������������������� 117
■
■Chapter 6: Working with Database Files����������������������������������������������������������� 119
■
■Chapter 7: Working with Tables������������������������������������������������������������������������� 155
■
■Chapter 8: Defining Fields��������������������������������������������������������������������������������� 171
■
■Chapter 9: Connecting Tables with Relationships��������������������������������������������� 203
■
■Chapter 10: Managing Containers��������������������������������������������������������������������� 233
■
■Chapter 11: Managing Value Lists��������������������������������������������������������������������� 243
iii
■ Contents at a Glance
■
■Part III: Writing Formulas and Using Functions������������������������������ 255
■
■Chapter 12: Writing Formulas��������������������������������������������������������������������������� 257
■
■Chapter 13: Text Functions�������������������������������������������������������������������������������� 291
■
■Chapter 14: Text Functions (JSON)�������������������������������������������������������������������� 313
■
■Chapter 15: Text Formatting Functions������������������������������������������������������������� 321
■
■Chapter 16: Number Functions�������������������������������������������������������������������������� 327
■
■Chapter 17: Date, Time, and Timestamp Functions������������������������������������������� 335
■
■Chapter 18: Container Functions����������������������������������������������������������������������� 343
■
■Chapter 19: Aggregate, Summary, and Repeating Functions���������������������������� 357
■
■Chapter 20: Financial and Trigonometric Functions������������������������������������������ 379
■
■Chapter 21: Logical Functions��������������������������������������������������������������������������� 385
■
■Chapter 22: Get Functions��������������������������������������������������������������������������������� 401
■
■Chapter 23: Design Functions���������������������������������������������������������������������������� 445
■
■Chapter 24: Mobile Functions���������������������������������������������������������������������������� 457
■
■Chapter 25: Creating Custom Functions������������������������������������������������������������ 461
■
■Chapter 26: Introducing ExecuteSQL����������������������������������������������������������������� 477
■
■Part IV: Designing Interfaces���������������������������������������������������������� 499
■
■Chapter 27: Introducing Layout Mode��������������������������������������������������������������� 501
■
■Chapter 28: Getting Started with Layouts��������������������������������������������������������� 519
■
■Chapter 29: Exploring Layout Palettes�������������������������������������������������������������� 559
■
■Chapter 30: Creating Layout Objects����������������������������������������������������������������� 589
■
■Chapter 31: Manipulating Objects��������������������������������������������������������������������� 661
■
■Chapter 32: Using Themes and Styles��������������������������������������������������������������� 681
■
■Chapter 33: Customizing Menus������������������������������������������������������������������������ 693
iv
■ Contents at a Glance
■
■Part V: Automating Tasks with Scripts������������������������������������������� 719
■
■Chapter 34: Introduction to Scripting���������������������������������������������������������������� 721
■
■Chapter 35: Common Scripting Tasks��������������������������������������������������������������� 749
■
■Chapter 36: Debugging Scripts�������������������������������������������������������������������������� 793
■
■Chapter 37: Using Script Triggers��������������������������������������������������������������������� 801
■
■Chapter 38: Extending Features with Plugins��������������������������������������������������� 815
■
■Part VI: Sharing and Networking���������������������������������������������������� 819
■
■Chapter 39: Introducing Network Sharing��������������������������������������������������������� 821
■
■Chapter 40: Securing Database Access������������������������������������������������������������� 851
■
■Chapter 41: Advanced Sharing and Analysis Tools������������������������������������������� 879
■
■Chapter 42: Getting Connected�������������������������������������������������������������������������� 895
Index��������������������������������������������������������������������������������������������������������������������� 899
v
Contents
■
■Part I: Using FileMaker����������������������������������������������������������������������� 1
■
■Chapter 1: Introducing FileMaker�������������������������������������������������������������������������� 3
The History of FileMaker in a Nutshell����������������������������������������������������������������������������� 3
Nashoba Nutshell����������������������������������������������������������������������������������������������������������������������������������� 3
Early FileMaker��������������������������������������������������������������������������������������������������������������������������������������� 4
FileMaker 4��������������������������������������������������������������������������������������������������������������������������������������������� 4
Claris������������������������������������������������������������������������������������������������������������������������������������������������������ 4
FileMaker Inc.����������������������������������������������������������������������������������������������������������������������������������������� 4
vii
■ Contents
Summary������������������������������������������������������������������������������������������������������������������������ 17
■
■Chapter 2: Exploring the Application������������������������������������������������������������������� 19
Installing and Launching FileMaker Pro������������������������������������������������������������������������� 19
Launching the Installer������������������������������������������������������������������������������������������������������������������������� 19
Running the Installation Process���������������������������������������������������������������������������������������������������������� 20
Launching the Application�������������������������������������������������������������������������������������������������������������������� 21
Default Windows������������������������������������������������������������������������������������������������������������ 21
Get Started Screen������������������������������������������������������������������������������������������������������������������������������� 21
Launch Center�������������������������������������������������������������������������������������������������������������������������������������� 22
Application Preferences������������������������������������������������������������������������������������������������� 23
General Settings����������������������������������������������������������������������������������������������������������������������������������� 23
Layout Settings������������������������������������������������������������������������������������������������������������������������������������� 25
Memory������������������������������������������������������������������������������������������������������������������������������������������������ 26
Plug-Ins������������������������������������������������������������������������������������������������������������������������������������������������ 26
Permitted Hosts������������������������������������������������������������������������������������������������������������������������������������ 27
viii
■ Contents
Format Menu���������������������������������������������������������������������������������������������������������������������������������������� 36
Records Menu��������������������������������������������������������������������������������������������������������������������������������������� 37
Scripts Menu���������������������������������������������������������������������������������������������������������������������������������������� 38
Tools Menu������������������������������������������������������������������������������������������������������������������������������������������� 38
Window Menu��������������������������������������������������������������������������������������������������������������������������������������� 39
Help Menu�������������������������������������������������������������������������������������������������������������������������������������������� 40
Contextual Menus����������������������������������������������������������������������������������������������������������� 40
Contextual Menus for Fields����������������������������������������������������������������������������������������������������������������� 42
Contextual Menus for Record Content Area������������������������������������������������������������������������������������������ 42
Contextual Menus for Web Viewers������������������������������������������������������������������������������������������������������ 42
Contextual Menus for Window Components����������������������������������������������������������������������������������������� 43
Contextual Menus for Calculation Formulas����������������������������������������������������������������������������������������� 43
Summary������������������������������������������������������������������������������������������������������������������������ 43
■
■Chapter 3: Exploring a Database Window����������������������������������������������������������� 45
Using a Starter Solution������������������������������������������������������������������������������������������������� 45
Listing FileMaker’s Starter Solutions���������������������������������������������������������������������������������������������������� 45
Creating a Database from a Starter Solution���������������������������������������������������������������������������������������� 46
ix
■ Contents
Summary������������������������������������������������������������������������������������������������������������������������ 60
■
■Chapter 4: Working with Records������������������������������������������������������������������������ 61
Entering Data������������������������������������������������������������������������������������������������������������������ 61
Opening a Record��������������������������������������������������������������������������������������������������������������������������������� 61
Understanding Field Focus������������������������������������������������������������������������������������������������������������������� 62
Moving to Another Field with Tab Order������������������������������������������������������������������������������������������������ 62
Modifying Field Contents���������������������������������������������������������������������������������������������������������������������� 63
Formatting Field Contents�������������������������������������������������������������������������������������������������������������������� 64
Closing a Record����������������������������������������������������������������������������������������������������������������������������������� 64
Managing Records��������������������������������������������������������������������������������������������������������� 65
Creating a New Record������������������������������������������������������������������������������������������������������������������������� 65
Deleting a Record��������������������������������������������������������������������������������������������������������������������������������� 65
Deleting All Records����������������������������������������������������������������������������������������������������������������������������� 66
Duplicating a Record���������������������������������������������������������������������������������������������������������������������������� 66
Searching for Records���������������������������������������������������������������������������������������������������� 67
Performing Fast Searches�������������������������������������������������������������������������������������������������������������������� 67
Using Find Mode����������������������������������������������������������������������������������������������������������������������������������� 70
Working with Found Sets����������������������������������������������������������������������������������������������� 84
Defining a Found Set���������������������������������������������������������������������������������������������������������������������������� 84
Changing the Records in the Found Set����������������������������������������������������������������������������������������������� 84
Sorting Records in the Found Set��������������������������������������������������������������������������������������������������������� 85
Modifying Field Values for Records in the Found Set��������������������������������������������������������������������������� 87
Find and Replace���������������������������������������������������������������������������������������������������������������������������������� 90
Spell Checking�������������������������������������������������������������������������������������������������������������������������������������� 91
Printing��������������������������������������������������������������������������������������������������������������������������� 93
Page Setup������������������������������������������������������������������������������������������������������������������������������������������� 93
Using Preview Mode����������������������������������������������������������������������������������������������������������������������������� 93
Print Dialog Options������������������������������������������������������������������������������������������������������������������������������ 96
Summary������������������������������������������������������������������������������������������������������������������������ 97
x
■ Contents
■
■Chapter 5: Transferring Data������������������������������������������������������������������������������� 99
Importing and Exporting Records����������������������������������������������������������������������������������� 99
Supported File Types�������������������������������������������������������������������������������������������������������������������������� 100
Downloading Sample Data����������������������������������������������������������������������������������������������������������������� 100
Importing Records������������������������������������������������������������������������������������������������������������������������������ 101
Exporting Records������������������������������������������������������������������������������������������������������������������������������ 110
■
■Part II: Defining Data Structures����������������������������������������������������� 117
■
■Chapter 6: Working with Database Files����������������������������������������������������������� 119
Creating a New Database File�������������������������������������������������������������������������������������� 119
Configuring a Sandbox Table���������������������������������������������������������������������������������������� 120
Changing the Default Table Name������������������������������������������������������������������������������������������������������ 120
Creating Data Entry Fields������������������������������������������������������������������������������������������������������������������ 121
Creating a Calculation Field���������������������������������������������������������������������������������������������������������������� 123
Creating a Summary Field������������������������������������������������������������������������������������������������������������������ 123
Setting Up Layouts����������������������������������������������������������������������������������������������������������������������������� 125
xi
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 153
■
■Chapter 7: Working with Tables������������������������������������������������������������������������� 155
Modeling Tables����������������������������������������������������������������������������������������������������������� 155
Introducing the Manage Database Dialog (Tables)������������������������������������������������������� 156
Table Properties���������������������������������������������������������������������������������������������������������������������������������� 157
Summary���������������������������������������������������������������������������������������������������������������������� 170
■
■Chapter 8: Defining Fields��������������������������������������������������������������������������������� 171
Defining Field Data Types��������������������������������������������������������������������������������������������� 172
Entry Fields����������������������������������������������������������������������������������������������������������������������������������������� 172
Display Fields������������������������������������������������������������������������������������������������������������������������������������� 176
xii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 201
■
■Chapter 9: Connecting Tables with Relationships��������������������������������������������� 203
Introducing Relationships��������������������������������������������������������������������������������������������� 203
Defining Relationships������������������������������������������������������������������������������������������������������������������������ 203
Defining Uses for Relationships���������������������������������������������������������������������������������������������������������� 204
Defining Connection Types����������������������������������������������������������������������������������������������������������������� 205
Organizing Relationships�������������������������������������������������������������������������������������������������������������������� 209
Planning the Learn FileMaker Relational Object Model���������������������������������������������������������������������� 212
xiii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 254
xiv
■ Contents
■
■Part III: Writing Formulas and Using Functions������������������������������ 255
■
■Chapter 12: Writing Formulas��������������������������������������������������������������������������� 257
Introducing Formulas��������������������������������������������������������������������������������������������������� 258
How Formulas Work��������������������������������������������������������������������������������������������������������������������������� 259
Summary���������������������������������������������������������������������������������������������������������������������� 290
■
■Chapter 13: Text Functions�������������������������������������������������������������������������������� 291
Text Function Reference����������������������������������������������������������������������������������������������� 291
Char���������������������������������������������������������������������������������������������������������������������������������������������������� 292
Code��������������������������������������������������������������������������������������������������������������������������������������������������� 293
Exact��������������������������������������������������������������������������������������������������������������������������������������������������� 293
Filter��������������������������������������������������������������������������������������������������������������������������������������������������� 294
FilterValues����������������������������������������������������������������������������������������������������������������������������������������� 294
Furigana��������������������������������������������������������������������������������������������������������������������������������������������� 295
xv
■ Contents
GetAsCSS�������������������������������������������������������������������������������������������������������������������������������������������� 295
GetAsDate������������������������������������������������������������������������������������������������������������������������������������������� 295
GetAsNumber�������������������������������������������������������������������������������������������������������������������������������������� 296
GetAsSVG�������������������������������������������������������������������������������������������������������������������������������������������� 297
GetAsText�������������������������������������������������������������������������������������������������������������������������������������������� 297
GetAsTime������������������������������������������������������������������������������������������������������������������������������������������ 298
GetAsTimestamp�������������������������������������������������������������������������������������������������������������������������������� 298
GetAsURLEncoded������������������������������������������������������������������������������������������������������������������������������ 299
GetValue��������������������������������������������������������������������������������������������������������������������������������������������� 299
Hiragana��������������������������������������������������������������������������������������������������������������������������������������������� 300
KanaHankaku������������������������������������������������������������������������������������������������������������������������������������� 300
KanaZenkaku�������������������������������������������������������������������������������������������������������������������������������������� 300
KanjiNumeral�������������������������������������������������������������������������������������������������������������������������������������� 300
Katakana��������������������������������������������������������������������������������������������������������������������������������������������� 300
Left����������������������������������������������������������������������������������������������������������������������������������������������������� 300
LeftValues������������������������������������������������������������������������������������������������������������������������������������������� 301
LeftWords������������������������������������������������������������������������������������������������������������������������������������������� 301
Length������������������������������������������������������������������������������������������������������������������������������������������������� 302
Lower�������������������������������������������������������������������������������������������������������������������������������������������������� 302
Middle������������������������������������������������������������������������������������������������������������������������������������������������� 302
MiddleValues�������������������������������������������������������������������������������������������������������������������������������������� 303
MiddleWords��������������������������������������������������������������������������������������������������������������������������������������� 303
NumToJText���������������������������������������������������������������������������������������������������������������������������������������� 303
PatternCount��������������������������������������������������������������������������������������������������������������������������������������� 303
Position����������������������������������������������������������������������������������������������������������������������������������������������� 304
Proper������������������������������������������������������������������������������������������������������������������������������������������������� 305
Quote�������������������������������������������������������������������������������������������������������������������������������������������������� 305
Replace����������������������������������������������������������������������������������������������������������������������������������������������� 306
Right��������������������������������������������������������������������������������������������������������������������������������������������������� 306
RightValues����������������������������������������������������������������������������������������������������������������������������������������� 306
RightWords����������������������������������������������������������������������������������������������������������������������������������������� 307
RomanHankaku���������������������������������������������������������������������������������������������������������������������������������� 307
xvi
■ Contents
RomanZenkaku����������������������������������������������������������������������������������������������������������������������������������� 307
SerialIncrement���������������������������������������������������������������������������������������������������������������������������������� 307
SortValues������������������������������������������������������������������������������������������������������������������������������������������ 308
Substitute������������������������������������������������������������������������������������������������������������������������������������������� 309
Trim����������������������������������������������������������������������������������������������������������������������������������������������������� 310
TrimAll������������������������������������������������������������������������������������������������������������������������������������������������� 310
UniqueValues�������������������������������������������������������������������������������������������������������������������������������������� 311
Upper�������������������������������������������������������������������������������������������������������������������������������������������������� 311
ValueCount������������������������������������������������������������������������������������������������������������������������������������������ 311
WordCount������������������������������������������������������������������������������������������������������������������������������������������ 312
Summary���������������������������������������������������������������������������������������������������������������������� 312
■
■Chapter 14: Text Functions (JSON)�������������������������������������������������������������������� 313
Introducing JSON��������������������������������������������������������������������������������������������������������� 313
Defining the JSON Format������������������������������������������������������������������������������������������������������������������ 313
Referring to JSON Elements��������������������������������������������������������������������������������������������������������������� 315
Summary���������������������������������������������������������������������������������������������������������������������� 320
■
■Chapter 15: Text Formatting Functions������������������������������������������������������������� 321
Text Formatting Function Reference���������������������������������������������������������������������������� 321
RGB����������������������������������������������������������������������������������������������������������������������������������������������������� 322
TextColor��������������������������������������������������������������������������������������������������������������������������������������������� 322
TextColorRemove�������������������������������������������������������������������������������������������������������������������������������� 323
TextFont���������������������������������������������������������������������������������������������������������������������������������������������� 323
TextFontRemove��������������������������������������������������������������������������������������������������������������������������������� 324
TextFormatRemove����������������������������������������������������������������������������������������������������������������������������� 324
xvii
■ Contents
TextSize���������������������������������������������������������������������������������������������������������������������������������������������� 325
TextSizeRemove��������������������������������������������������������������������������������������������������������������������������������� 325
TextStyleAdd��������������������������������������������������������������������������������������������������������������������������������������� 326
TextStyleRemove�������������������������������������������������������������������������������������������������������������������������������� 326
Summary���������������������������������������������������������������������������������������������������������������������� 326
■
■Chapter 16: Number Functions�������������������������������������������������������������������������� 327
Number Function Reference���������������������������������������������������������������������������������������� 327
Abs������������������������������������������������������������������������������������������������������������������������������������������������������ 328
Ceiling������������������������������������������������������������������������������������������������������������������������������������������������� 328
Combination��������������������������������������������������������������������������������������������������������������������������������������� 328
Div������������������������������������������������������������������������������������������������������������������������������������������������������ 329
Exp������������������������������������������������������������������������������������������������������������������������������������������������������ 329
Factorial���������������������������������������������������������������������������������������������������������������������������������������������� 330
Floor��������������������������������������������������������������������������������������������������������������������������������������������������� 330
Int������������������������������������������������������������������������������������������������������������������������������������������������������� 330
Lg�������������������������������������������������������������������������������������������������������������������������������������������������������� 331
Ln�������������������������������������������������������������������������������������������������������������������������������������������������������� 331
Log������������������������������������������������������������������������������������������������������������������������������������������������������ 331
Mod����������������������������������������������������������������������������������������������������������������������������������������������������� 332
Random���������������������������������������������������������������������������������������������������������������������������������������������� 332
Round������������������������������������������������������������������������������������������������������������������������������������������������� 333
SetPrecision���������������������������������������������������������������������������������������������������������������������������������������� 333
Sign���������������������������������������������������������������������������������������������������������������������������������������������������� 333
Sqrt����������������������������������������������������������������������������������������������������������������������������������������������������� 334
Truncate���������������������������������������������������������������������������������������������������������������������������������������������� 334
Summary���������������������������������������������������������������������������������������������������������������������� 334
■
■Chapter 17: Date, Time, and Timestamp Functions������������������������������������������� 335
Date Function Reference���������������������������������������������������������������������������������������������� 335
Date���������������������������������������������������������������������������������������������������������������������������������������������������� 336
Day����������������������������������������������������������������������������������������������������������������������������������������������������� 336
DayName�������������������������������������������������������������������������������������������������������������������������������������������� 336
xviii
■ Contents
DayNameJ������������������������������������������������������������������������������������������������������������������������������������������ 337
DayOfWeek����������������������������������������������������������������������������������������������������������������������������������������� 337
DayOf Year������������������������������������������������������������������������������������������������������������������������������������������ 337
Month������������������������������������������������������������������������������������������������������������������������������������������������� 337
MonthName���������������������������������������������������������������������������������������������������������������������������������������� 338
MonthNameJ�������������������������������������������������������������������������������������������������������������������������������������� 338
WeekOfYear���������������������������������������������������������������������������������������������������������������������������������������� 338
WeekOfYearFiscal������������������������������������������������������������������������������������������������������������������������������� 339
Year����������������������������������������������������������������������������������������������������������������������������������������������������� 339
YearName������������������������������������������������������������������������������������������������������������������������������������������� 339
Summary���������������������������������������������������������������������������������������������������������������������� 342
■
■Chapter 18: Container Functions����������������������������������������������������������������������� 343
Container Function Reference�������������������������������������������������������������������������������������� 343
Base64Decode������������������������������������������������������������������������������������������������������������������������������������ 343
Base64Encode������������������������������������������������������������������������������������������������������������������������������������ 344
Base64EncodeRFC������������������������������������������������������������������������������������������������������������������������������ 344
CryptAuthCode������������������������������������������������������������������������������������������������������������������������������������ 345
CryptEncrypt��������������������������������������������������������������������������������������������������������������������������������������� 346
CryptEncryptBase64��������������������������������������������������������������������������������������������������������������������������� 346
CryptDecrypt��������������������������������������������������������������������������������������������������������������������������������������� 347
CryptDecryptBase64��������������������������������������������������������������������������������������������������������������������������� 347
CryptDigest����������������������������������������������������������������������������������������������������������������������������������������� 347
GetContainerAttribute������������������������������������������������������������������������������������������������������������������������� 348
Examples�������������������������������������������������������������������������������������������������������������������������������������������� 350
xix
■ Contents
GetHeight�������������������������������������������������������������������������������������������������������������������������������������������� 351
GetThumbnail������������������������������������������������������������������������������������������������������������������������������������� 352
GetWidth��������������������������������������������������������������������������������������������������������������������������������������������� 352
HexEncode������������������������������������������������������������������������������������������������������������������������������������������ 353
HexDecode������������������������������������������������������������������������������������������������������������������������������������������ 353
TextEncode����������������������������������������������������������������������������������������������������������������������������������������� 354
TextDecode����������������������������������������������������������������������������������������������������������������������������������������� 354
VerifyContainer����������������������������������������������������������������������������������������������������������������������������������� 355
Summary���������������������������������������������������������������������������������������������������������������������� 355
■
■Chapter 19: Aggregate, Summary, and Repeating Functions���������������������������� 357
Aggregate Function Reference������������������������������������������������������������������������������������� 357
Average ���������������������������������������������������������������������������������������������������������������������������������������������� 358
Count�������������������������������������������������������������������������������������������������������������������������������������������������� 360
List������������������������������������������������������������������������������������������������������������������������������������������������������ 362
Max ���������������������������������������������������������������������������������������������������������������������������������������������������� 363
Min ����������������������������������������������������������������������������������������������������������������������������������������������������� 365
StDev ������������������������������������������������������������������������������������������������������������������������������������������������� 367
StDevP ����������������������������������������������������������������������������������������������������������������������������������������������� 369
Sum ��������������������������������������������������������������������������������������������������������������������������������������������������� 370
Variance ��������������������������������������������������������������������������������������������������������������������������������������������� 372
VarianceP ������������������������������������������������������������������������������������������������������������������������������������������� 374
Summary Functions����������������������������������������������������������������������������������������������������� 376
GetSummary �������������������������������������������������������������������������������������������������������������������������������������� 376
Summary���������������������������������������������������������������������������������������������������������������������� 378
■
■Chapter 20: Financial and Trigonometric Functions������������������������������������������ 379
Financial Function Reference��������������������������������������������������������������������������������������� 379
FV�������������������������������������������������������������������������������������������������������������������������������������������������������� 379
xx
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 384
■
■Chapter 21: Logical Functions��������������������������������������������������������������������������� 385
Logical Function Reference������������������������������������������������������������������������������������������ 385
Case ��������������������������������������������������������������������������������������������������������������������������������������������������� 386
Choose ����������������������������������������������������������������������������������������������������������������������������������������������� 386
Evaluate���������������������������������������������������������������������������������������������������������������������������������������������� 387
EvaluationError ���������������������������������������������������������������������������������������������������������������������������������� 388
ExecuteSQL����������������������������������������������������������������������������������������������������������������������������������������� 389
GetAsBoolean ������������������������������������������������������������������������������������������������������������������������������������ 389
GetAVPlayerAttribute ������������������������������������������������������������������������������������������������������������������������� 389
GetField ��������������������������������������������������������������������������������������������������������������������������������������������� 390
GetFieldName ������������������������������������������������������������������������������������������������������������������������������������ 391
GetLayoutObjectAttribute ������������������������������������������������������������������������������������������������������������������� 392
GetNthRecord ������������������������������������������������������������������������������������������������������������������������������������ 394
If �������������������������������������������������������������������������������������������������������������������������������������������������������� 394
IsEmpty ���������������������������������������������������������������������������������������������������������������������������������������������� 395
IsValid ������������������������������������������������������������������������������������������������������������������������������������������������ 395
IsValidExpression ������������������������������������������������������������������������������������������������������������������������������� 395
xxi
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 399
■
■Chapter 22: Get Functions��������������������������������������������������������������������������������� 401
Get Function Reference������������������������������������������������������������������������������������������������ 401
Get ( AccountExtendedPrivileges )������������������������������������������������������������������������������������������������������ 404
Get ( AccountGroupName )����������������������������������������������������������������������������������������������������������������� 405
Get ( AccountName )��������������������������������������������������������������������������������������������������������������������������� 405
Get ( AccountPrivilegeSetName )�������������������������������������������������������������������������������������������������������� 405
Get ( ActiveFieldContents )������������������������������������������������������������������������������������������������������������������ 406
Get ( ActiveFieldName )���������������������������������������������������������������������������������������������������������������������� 406
Get ( ActiveFieldTableName )�������������������������������������������������������������������������������������������������������������� 406
Get ( ActiveLayoutObjectName )��������������������������������������������������������������������������������������������������������� 406
Get ( ActiveModifierKeys )������������������������������������������������������������������������������������������������������������������� 407
Get ( ActivePortalRowNumber )���������������������������������������������������������������������������������������������������������� 407
Get ( ActiveRepetitionNumber )���������������������������������������������������������������������������������������������������������� 408
Get ( ActiveSelectionSize )������������������������������������������������������������������������������������������������������������������ 408
Get ( ActiveSelectionStart )����������������������������������������������������������������������������������������������������������������� 408
Get ( AllowAbortState )����������������������������������������������������������������������������������������������������������������������� 409
Get ( AllowFormattingBarState )��������������������������������������������������������������������������������������������������������� 409
Get ( ApplicationArchitecture )������������������������������������������������������������������������������������������������������������ 409
Get ( ApplicationLanguage )���������������������������������������������������������������������������������������������������������������� 410
Get ( ApplicationVersion )�������������������������������������������������������������������������������������������������������������������� 410
Get ( CalculationRepetitionNumber )�������������������������������������������������������������������������������������������������� 411
Get ( ConnectionAttributes )���������������������������������������������������������������������������������������������������������������� 411
Get ( ConnectionState )����������������������������������������������������������������������������������������������������������������������� 411
Get ( CurrentDate )������������������������������������������������������������������������������������������������������������������������������ 412
Get ( CurrentExtendedPrivileges )������������������������������������������������������������������������������������������������������� 412
Get ( CurrentHostTimestamp )������������������������������������������������������������������������������������������������������������ 412
xxii
■ Contents
xxiii
■ Contents
xxiv
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 443
xxv
■ Contents
■
■Chapter 23: Design Functions���������������������������������������������������������������������������� 445
Design Function Reference������������������������������������������������������������������������������������������ 445
DatabaseNames �������������������������������������������������������������������������������������������������������������������������������� 446
FieldBounds ��������������������������������������������������������������������������������������������������������������������������������������� 446
FieldComment ����������������������������������������������������������������������������������������������������������������������������������� 447
FieldIDs ���������������������������������������������������������������������������������������������������������������������������������������������� 447
FieldNames ���������������������������������������������������������������������������������������������������������������������������������������� 448
FieldRepetitions ��������������������������������������������������������������������������������������������������������������������������������� 448
FieldStyle ������������������������������������������������������������������������������������������������������������������������������������������� 449
FieldType ������������������������������������������������������������������������������������������������������������������������������������������� 449
GetNextSerialValue ���������������������������������������������������������������������������������������������������������������������������� 450
LayoutIDs ������������������������������������������������������������������������������������������������������������������������������������������� 450
LayoutNames ������������������������������������������������������������������������������������������������������������������������������������� 451
LayoutObjectNames ��������������������������������������������������������������������������������������������������������������������������� 451
RelationInfo ��������������������������������������������������������������������������������������������������������������������������������������� 452
ScriptIDs �������������������������������������������������������������������������������������������������������������������������������������������� 453
ScriptNames �������������������������������������������������������������������������������������������������������������������������������������� 453
TableIDs ��������������������������������������������������������������������������������������������������������������������������������������������� 453
TableNames ��������������������������������������������������������������������������������������������������������������������������������������� 454
ValueListIDs ��������������������������������������������������������������������������������������������������������������������������������������� 454
ValueListItems ����������������������������������������������������������������������������������������������������������������������������������� 455
ValueListNames ��������������������������������������������������������������������������������������������������������������������������������� 455
WindowNames ����������������������������������������������������������������������������������������������������������������������������������� 456
Summary���������������������������������������������������������������������������������������������������������������������� 456
■
■Chapter 24: Mobile Functions���������������������������������������������������������������������������� 457
Mobile Function Reference������������������������������������������������������������������������������������������ 457
Location ��������������������������������������������������������������������������������������������������������������������������������������������� 457
LocationValues ���������������������������������������������������������������������������������������������������������������������������������� 458
RangeBeacons ����������������������������������������������������������������������������������������������������������������������������������� 459
Summary���������������������������������������������������������������������������������������������������������������������� 460
xxvi
■ Contents
■
■Chapter 25: Creating Custom Functions������������������������������������������������������������ 461
Defining Custom Functions������������������������������������������������������������������������������������������ 461
Exploring the Custom Function Dialogs������������������������������������������������������������������������ 462
The Manage Custom Functions Dialog����������������������������������������������������������������������������������������������� 462
The Edit Custom Function Dialog�������������������������������������������������������������������������������������������������������� 464
Summary���������������������������������������������������������������������������������������������������������������������� 475
■
■Chapter 26: Introducing ExecuteSQL����������������������������������������������������������������� 477
Defining the ExecuteSQL Function������������������������������������������������������������������������������� 478
How the ExecuteSQL Function Works������������������������������������������������������������������������������������������������� 478
Understanding Some Limitations of ExecuteSQL������������������������������������������������������������������������������� 480
■
■Part IV: Designing Interfaces���������������������������������������������������������� 499
■
■Chapter 27: Introducing Layout Mode��������������������������������������������������������������� 501
Emphasizing the Importance of Layout Design������������������������������������������������������������ 501
Using Layout Mode������������������������������������������������������������������������������������������������������� 502
Identifying Layout Mode��������������������������������������������������������������������������������������������������������������������� 502
Status Toolbar (Layout Mode)������������������������������������������������������������������������������������������������������������� 504
Menu Changes (Layout Mode)������������������������������������������������������������������������������������������������������������ 509
Summary���������������������������������������������������������������������������������������������������������������������� 518
■
■Chapter 28: Getting Started with Layouts��������������������������������������������������������� 519
Planning Layouts���������������������������������������������������������������������������������������������������������� 519
Classifying Layouts into Type Categories������������������������������������������������������������������������������������������� 519
Sketching a Layout Flow Chart����������������������������������������������������������������������������������������������������������� 523
Summary���������������������������������������������������������������������������������������������������������������������� 588
■
■Chapter 30: Creating Layout Objects����������������������������������������������������������������� 589
Introducing Layout Objects������������������������������������������������������������������������������������������ 589
Inserting an Object onto the Layout���������������������������������������������������������������������������������������������������� 590
Configuring an Object������������������������������������������������������������������������������������������������������������������������� 590
xxix
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 660
■
■Chapter 31: Manipulating Objects��������������������������������������������������������������������� 661
Selecting Objects��������������������������������������������������������������������������������������������������������� 661
Resizing Objects����������������������������������������������������������������������������������������������������������� 662
Moving Objects������������������������������������������������������������������������������������������������������������� 662
Layout Positioning Helpers����������������������������������������������������������������������������������������������������������������� 663
xxx
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 691
■
■Chapter 33: Customizing Menus������������������������������������������������������������������������ 693
Exploring the Capabilities of Customize Menus����������������������������������������������������������� 693
Getting Started with Custom Menus Basics����������������������������������������������������������������� 694
Exploring Custom Menu Set Options�������������������������������������������������������������������������������������������������� 695
Understanding Customization Exceptions������������������������������������������������������������������������������������������ 696
xxxi
■ Contents
■
■Part V: Automating Tasks with Scripts������������������������������������������� 719
■
■Chapter 34: Introduction to Scripting���������������������������������������������������������������� 721
Identifying the Benefits of Scripting����������������������������������������������������������������������������� 721
Exploring Scripting Basics������������������������������������������������������������������������������������������� 722
Calling Other Scripts��������������������������������������������������������������������������������������������������������������������������� 723
Understanding the Importance of Context������������������������������������������������������������������������������������������ 727
Summary���������������������������������������������������������������������������������������������������������������������� 748
■
■Chapter 35: Common Scripting Tasks��������������������������������������������������������������� 749
Allowing User Abort������������������������������������������������������������������������������������������������������ 749
Setting Variables���������������������������������������������������������������������������������������������������������� 750
Creating Navigation Scripts������������������������������������������������������������������������������������������ 751
Go to Layout���������������������������������������������������������������������������������������������������������������������������������������� 751
Go to Record/Request/Page���������������������������������������������������������������������������������������������������������������� 753
Go to Related Record�������������������������������������������������������������������������������������������������������������������������� 754
xxxii
■ Contents
xxxiii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 814
■
■Chapter 38: Extending Features with Plugins��������������������������������������������������� 815
Purchasing Plug-Ins����������������������������������������������������������������������������������������������������� 815
360 Works������������������������������������������������������������������������������������������������������������������������������������������� 815
Productive Computing������������������������������������������������������������������������������������������������������������������������ 815
Trio Automatisering����������������������������������������������������������������������������������������������������������������������������� 816
Finding Other Plug-ins������������������������������������������������������������������������������������������������������������������������ 816
Locating Installed Plug-Ins����������������������������������������������������������������������������������������������������������������� 816
xxxiv
■ Contents
■
■Part VI: Sharing and Networking���������������������������������������������������� 819
■
■Chapter 39: Introducing Network Sharing��������������������������������������������������������� 821
How Network Sharing Works��������������������������������������������������������������������������������������� 821
Limitations to Sharing������������������������������������������������������������������������������������������������������������������������ 823
Summary���������������������������������������������������������������������������������������������������������������������� 849
■
■Chapter 40: Securing Database Access������������������������������������������������������������� 851
Exploring the Benefits of Security�������������������������������������������������������������������������������� 851
Defining Default Security��������������������������������������������������������������������������������������������� 851
Exploring the Security Dialog��������������������������������������������������������������������������������������� 852
Exploring the Interface Modes������������������������������������������������������������������������������������������������������������ 853
■
■Chapter 41: Advanced Sharing and Analysis Tools������������������������������������������� 879
Database Design Report����������������������������������������������������������������������������������������������� 879
Generating a Design Report���������������������������������������������������������������������������������������������������������������� 879
Exploring a Design Report������������������������������������������������������������������������������������������������������������������ 881
Introducing Professional DDR Tools���������������������������������������������������������������������������������������������������� 884
Summary���������������������������������������������������������������������������������������������������������������������� 894
■
■Chapter 42: Getting Connected�������������������������������������������������������������������������� 895
Connect with Mark Munro�������������������������������������������������������������������������������������������� 895
Learn FileMaker Pro 16 Official Sites��������������������������������������������������������������������������� 895
FileMaker Inc. �������������������������������������������������������������������������������������������������������������� 896
Database Design Report (DDR) Analysis Tools�������������������������������������������������������������� 896
Plug-Ins������������������������������������������������������������������������������������������������������������������������ 896
Communities���������������������������������������������������������������������������������������������������������������� 896
Technology Sites���������������������������������������������������������������������������������������������������������� 897
Function Background Information�������������������������������������������������������������������������������� 897
Index��������������������������������������������������������������������������������������������������������������������� 899
xxxvi
About the Author
Mark Conway Munro is an author, software developer and entrepreneur. A 1988 introduction to FileMaker
led Mark to pursue a career as a developer. Soon after, he was using AppleScript and FileMaker for
information management and process automation. In 1994, Mark founded Write Track Media, a computer
consultancy to develop custom database and workflow automation solutions for clients.
Today, Mark continues in that mission, using AppleScript and FileMaker Pro in combination with other
tools and technologies to build time-saving systems for a diverse list of clients. By fully understanding the
virtue of using technology to free humans from repetitive computer tasks so they can pursue a higher level of
productivity, Mark’s passion for the work is unwavering.
Mark is also the author of AppleScript: Developer Reference (2010, Wiley).
xxxvii
About the Technical Reviewer
Brian Sanchez is a FileMaker developer, a consultant with wide experience, and a founding member of
aACE Software. Brian’s experience is wide reaching. For nearly 20 years, he has designed and implemented
custom apps for inventory tracking, digital catalogs built with FileMaker Go, plus asset management and
pricing tools. His clients range from catering businesses to TV casting agencies to European vacationing
services. Brian holds multiple FileMaker certifications. His development philosophy is to build systems with
such integrity in the code and architecture that the client never needs to call again — unless they’re looking
to upgrade the solution. Brian is the technical editor of Learn FileMaker Pro 16 (2017, Apress).
xxxix
Foreword
In the 1990s and 2000s, I ran TECSoft, an AppleScript and FileMaker Pro development shop in New York
City. Our specialty was database publishing – the powerful ability of Apple’s AppleScript technology
to intelligently extract data from FileMaker databases and to format it ready-for-print in page layout
applications such as QuarkXPress and Adobe InDesign.
We worked closely with Apple and Claris, the predecessor of FileMaker Inc., to showcase the abilities of
their technologies. In 1994, growing – and needing additional developer talent, we asked our pal Eric Silver,
the then New York area sales rep at Claris, to be on the lookout for us. He told me about a FileMaker wizard
he knew named Mark Munro working at Jack Morton, an AV production company in New York.
Mark was responsible for organizing Morton’s production project data and managing their workflow.
We met and he explained their workflow and showed me how he had organized it in FileMaker so that
management was able to track projects from start to finish, track the various assets involved, and track and
accurately bill their clients for the time and materials involved.
Mark’s work was amazing and I immediately realized we had come across FileMaker gold. All aspects
of his company’s workflow were logically organized in a functional workflow management tool – and most
impressively of all – was clearly presently in an easy-to-follow interface. It is mind-bending to realize that
Mark had accomplished this before FileMaker was a relational database.
We began working with Mark as a freelance FileMaker Pro and AppleScript gun slinger. We threw our
most complicated and demanding projects at him – a huge workflow management and catalog publishing
project at Sony Music, a very complex and mission-critical graphic file creation project with drop-dead
deadlines for Associated Press, to name just a couple.
In short order, Mark had more than enough work to go out on his own as a full-time FileMaker and
AppleScript developer. As TECSoft’s focus turned to working with Apple delivering AppleScript seminars
and training sessions, we created the TECSoft Developers Consortium (TDC) to handle the huge demand
for FileMaker and AppleScript integration projects our seminars generated. With Mark as TDC developer #1,
we were able to create an international referral network of FileMaker Pro and AppleScript developers that
became the largest FileMaker Pro and AppleScript brain trust on earth.
Mark has now been running his own successful development company, Write Track Media, for
over 20 years. What Mark possesses, more than any other developer I’ve worked with, is a true talent for
organization. Mark’s passion makes him eminently qualified to pass along his mastery of FileMaker’s
powerful organization tool. He just had to write this book.
John Thorsen Jr.
Connected Hearth, LLC
xli
Acknowledgments
This book was an enormous challenge and would not have been possible without the contributions and
encouragement of many.
Some long overdue thanks to Peter Samelson and Tony Spina who played a role in my early introduction
to FileMaker decades ago. To Sylvia Griffiths for hiring me at Jack Morton and to Laura Shuler for asking me
to develop a budget management database. To John Thorsen, Jr., for development opportunities he offered
me and for being such a prolific source of advice, knowledge, and humor.
Continuing thanks to all my incredible clients for finding new challenges that push me to find new
technological solutions to improve their database and workflow systems.
To the whole team at Apress for providing me with this opportunity and for all their hard work in
bringing everything together.
Most of all, a huge thanks to two close friends. To Brian Sanchez for his work reviewing the material
with a keen eye for technical accuracy. His feedback led to many key improvements that greatly enhanced
the quality of the material. Also, to Walker Stevenson for reading a draft of the manuscript and providing
some additional technical notes and suggestions for improvement.
xliii
Introduction
Back in late-1988 while working at Tannen’s Magic Store in Manhattan, I was introduced to FileMaker. A
discussion arose about using computers to improve the efficiency and accuracy of the pen and paper-based
ordering system. To do that, we first needed to enter the inventory into a database. My boss handed me what
was then a state of the art personal computer; a Macintosh SE, which was a small box with a tiny 9-inch
black and white screen. It was loaded with a copy of the newly released FileMaker II by Claris Corporation.
That version was expressed in Roman numerals and this was two years before the “Pro” suffix would be
added and the versioning reset to 1.0.
With the computer, a small rolling cart and a long extension cord, I headed into the stock room to
begin computerizing the inventory. I barely used a computer prior to that day and it was my first glimpse
at FileMaker. I spent about ten minutes becoming acquainted with the software, then quickly created a
database file and set up a handful of fields. This rapid adoption is not so much a testament to my intuitive
ability with software but more attributable to the extremely primitive nature of that early version. The
database I created was extraordinarily crude but it allowed us to begin entering product information and
to print on paper “labels” that could be taped onto product boxes to improve the hand-written names and
prices.
For the next few weeks, with the help of another employee, I entered batches of products into the
database. There was no network at the store at the time, so we periodically shuttled the database by 3.5”
floppy disk to the main office computer to print out box labels displaying the information. These were affixed
to boxes as the next batch of products were entered. Finally, we had a complete database of every available
product. From there, I developed an order management system that pulled product information from that
inventory file and installed a small network of computers each with access to a server. The project changed
order fulfillment at the store and the course of my life.
Fast forward almost three decades, about twenty significant version increments later and we reach
FileMaker Pro 16, an astonishingly powerful piece of software. Keeping with tradition, it is packed with
features for users and developers in an integrated application. It contains a development environment
and a customizable runtime. It balances an ease of use making it approachable by beginners and contains
powerful standard technologies and robust customization options demanded by professionals.
The age of the software and its multi-decade evolution shows in an esthetic hodgepodge of styles
throughout the development interface. The design of some dialogs look a little dated when compared to
the newer additions; palettes and workspaces sporting a modern design. This seems to hint at a steadfast
dedication to stability and a desire to avoid the frequent pitfall of many software titles; changing things for
the sake of changing things. This gradual evolution of components contributes to the stable nature of the
software across time even as it routinely takes leaps to evolve and keep pace with new technologies.
xlv
■ Introduction
The complexity of different modes and perspectives so tightly integrated in a single application, and
the sheer number of functions, tools and customization options available proved a challenge when deciding
how to best present the material in a book. In the end, I divided the material into the following six parts,
logically arranged in a hierarchy so that each chapter builds on the previous:
• Part 1 — Using FileMaker
• Part 2 — Defining Data Structures
• Part 3 — Writing Formulas and Using Functions
• Part 4 — Designing Interfaces
• Part 5 — Automating Tasks with Scripts
• Part 6 — Sharing and Networking
My hope is that the arrangement of material might serve both those who want to read it cover to cover
and those who use it as a reference guide to look up specific topics and examples. I would enjoy hearing
from you about your experience with the book and am open to suggestions for how to improve future
editions. If you want to send feedback, ask a question, or read exclusive online content, visit my website for
the book:
www.learn-filemaker.com
Unlike those early versions I used decades ago, FileMaker Pro 16 is a mature application with a solid
track record, evolving feature set, substantial user base that should appeal to professional developers.
And, while no one today should expect to learn it in ten minutes, it is still approachable for beginners and
casual programmers. I hope this book convinces people to give it a try, both seasoned professionals and
newcomers who are beginning their adventure into the world of custom database development.
Mark Conway Munro
May 2017 / Lewisburg, PA
xlvi
PART I
Using FileMaker
FileMaker Pro combines a runtime user interface with a development environment into a single
application. To become familiar with the software, start by reviewing the basics of using the software
from a user perspective.
These five chapters are intended primarily for newcomers so readers who have prior experience
using databases built with FileMaker may find some of this material relatively basic. However,
experienced users and expert developers who are looking to brush up on the latest features may
appreciate this as a solid foundation for the remaining portions of the book.
The topics covered in these chapters include:
1.
Introducing FileMaker — Includes the history of FileMaker, database
basics and architectures, a bird’s eye overview of FileMaker’s unique
architecture and the entire FileMaker product family.
2.
Exploring the Application — Includes FileMaker Pro installation process,
default windows, application preferences, the default Browse mode
menu bar, and various contextual menus throughout the interface.
3.
Exploring a Database Window — Using a FileMaker-provided Contacts
starter solution, this includes the anatomy of a database window, how to
use windows, and how to open an existing database.
4.
Working with Records — Explores the process of entering, managing,
searching, and printing records.
5.
Transferring Data — Provides an overview of the various methods of
importing and exporting records.
CHAPTER 1
Introducing FileMaker
FileMaker Pro is a relational data management system published by Apple subsidiary FileMaker Inc.
Since its origin, the product has expanded and evolved with improved capabilities to keep pace with
standard technologies. The current incarnation is a powerful, feature-rich and easy-to-use integrated
development tool, available in fifteen different languages. FileMaker databases can be shared across a
network with multiple simultaneous users working on Mac and Windows computers as well as iOS devices.
FileMaker is popular with millions of developers and users, including independent consultants,
employees of small businesses, and members of teams working at medium to large businesses, non-profits,
and government agencies. Beginners are empowered by the ease of use and approachable interface.
Professionals are won over by its rapid development capabilities for prototyping and the ability to build
powerful user-friendly solutions. Business owners who don’t have time to learn to program can easily find a
professional consultant to develop a system tailored to meet their individual needs.
Whatever your skill set, if you are frustrated with an existing database system or are looking to develop
something new, FileMaker is an excellent choice.
In this chapter, we introduce FileMaker by discussing topics such as the following:
• The history of FileMaker in a Nutshell
• Exploring database basics
• Identifying different database architectures
• Taking a bird’s eye anatomical and functional overview
• The FileMaker product family
Nashoba Nutshell
FileMaker started its life in the early 1980s as Nutshell, an MS-DOS computer program that was developed by
Nashoba Systems in Concord, Massachusetts, and distributed by electronics marketer Leading Edge.
Early FileMaker
When the Macintosh computer was introduced in early 1984, Nashoba saw an opportunity. They worked
to combine the database engine with a graphic user interface and created a new forms-based database
product. When Leading Edge announced that they wished to remain a DOS-only vendor, Nashoba
began working with a new distributor. Forethought, Inc. FileMaker v1.0 was released in April 1985 for the
Macintosh platform. In 1986, it was renamed FileMaker Plus to match the release of the Macintosh Plus.
By today’s standards, the early versions of FileMaker were incredibly crude and limited in capabilities.
However, for the time, the software filled an important need with an easy-to-use design and steadily became
popular with the do-it-yourself crowd.
FileMaker 4
When Microsoft purchased Forethought, they tried to negotiate a purchase of FileMaker, which was
outselling their own Microsoft File database application. However, Nashoba declined and decided to begin
self-publishing the program, now named FileMaker 4.
Claris
In 1987, Apple formed Claris Corp. as a wholly owned subsidiary to develop and publish Macintosh software
titles such as MacWrite and MacPaint. In 1988, Claris purchased Nashoba Systems to acquire FileMaker.
By this time Leading Edge and Nutshell had disappeared as other DOS and Windows database products
dominated the market.
In 1988, FileMaker II was released by Claris to match the naming scheme of their other products. After
a few minor updates, the product was rebranded in 1990 under its modern naming format when FileMaker
Pro version 1.0 was released.
Claris upgraded the product in 1992 with Windows support, making FileMaker Pro 2.0 the first cross-
platform version. They began publishing a server application in 1994. It wasn’t until 1995 with the release of
version 3.0 that FileMaker became fully relational.
By 1997, with version 4.0, FileMaker was a widely popular product and was outselling all other Claris
products. Apple absorbed those products in-house and renamed the subsidiary after their only remaining
product.
FileMaker Inc.
FileMaker Inc., the newly renamed subsidiary, released FileMaker Pro 4.1v2 in June of 1999. Since that time,
they have steadily improved and expanded the product. Some highlights are included in Table 1-1.
4
Chapter 1 ■ Introducing FileMaker
Table 1-1. A summary of major new features in recent FileMaker Pro versions
Since its start in 1985 as a modest, single-user database, the product has greatly improved. What began
as a simple, easy-to-use tool for non-technical people has matured into a considerably more sophisticated
platform. Today, FileMaker offers an astonishing array of technical features and capabilities that are sure to
fill the most advanced development needs. By integrating this power with an intuitive graphical interface, it
continues to be approachable by those new to programming.
Defining a Database
A database is a structured collection of information efficiently stored in a generic format that makes it easily
accessibility for reuse in a variety of different ways.
Most applications are focused on one specific data type with predefined properties and procedures.
A calendar application allows a user to create and manage events with properties of date, time, attendees,
notes, and alerts. Similarly, an email application allows management of messages with predefined
properties of sender, recipients, subject, and body. These could each be thought of colloquially as an “event-
base” and a “message-base” since, at their base, they store and provide access to events and messages.
From a wider perspective, both events and messages are types of information; they are both forms of
data. A calendar app manages an event database. A mail application manages a message database. Unlike
these, an open-ended database application like FileMaker Pro has no predefined data type; at its base
is data, any data. It allows a developer-user to create a custom management system for any kind of data
depending on a specific custom need.
5
Chapter 1 ■ Introducing FileMaker
Specific applications, such as the calendar or mail app mentioned above, provide a metaphorical filing
cabinet that is locked and preconfigured to fit only certain predefined folders containing a specific type of
information. A user is free to enter information into this predefined framework but have little or no control
over the framework itself. By contrast, a database is the metaphorical equivalent of that same filing drawer
completely empty and unlocked so that you can define the content it accepts, how that information is stored,
related, displayed, used and shared. Every project starts fresh with the same blank slate waiting for you to
define the framework and establish the capabilities it will make available to the user.
Databases can store information about anything a developer defines them to manage: companies,
messages, notes, people, products, tasks, etc.
Database Structure
Fundamentally, a database is made up of only a few basic components. These include tables, relationships, a
user interface, and scripted procedures.
A table can be visualized as a set of rows and columns in a spreadsheet tab that is dedicated to a single
type of entity. The simple table example, shown in Figure 1-1, is modeled after People.
Table
People
Cell Field
A field, represented by a column in the table, is a defined container in which one piece of information
about the entity modeled will be stored. In the example shown, each component of a name and address is an
individual field.
A record, represented by a row in the table, is one individual entity stored within a table. While the table
in the example represents people in general, a row, or record, represents one person. The record is one
instance of the table’s defined field set containing information about a specific person.
A cell is the formal name of an intersection of a field and record. In FileMaker, these are commonly
referred to as fields with the understanding that each is an instance of a field for a record (cell), which is
distinct from the field definition itself (field).
6
Chapter 1 ■ Introducing FileMaker
Relational Databases
A database is considered relational when its tables can be interconnected to form relationships between
the records they contain based on one or more key fields. While any field can act as a key, most often a
unique identification number is assigned to each record, which is used to locate matching values in a field in
another table.
A relationship allows information from one table to be accessed from the other through the
connection. They allow data to be stored in separate tables but used elsewhere and help to eliminate
redundant data entry.
Company
ID Name
00002 Apple
000003 FileMaker
People
Company ID
00001
00026
000001
A relationship, like the one shown in Figure 1-2, is a connection between two tables established by
linking one or more fields from one table to one or more fields in another. In this example, the unique ID
field in the Company table is linked to the Company ID field in the People table forming the relationship.
We see that there are two matches, meaning two people have been linked to the same company. Using the
relationship, the two-related people can be displayed on a layout for the company and used in calculations
and scripted procedures from within that context.
User Interface
The user interface is made up of the layouts, menus, and windows that allows the user to view and interact
with the data in a graphical, human-friendly format.
A layout is a visual display of fields and controls from the perspective of a single table’s records. Tables
can have many layouts for different purposes. For example, a list layout might show a couple fields for all the
records for a table to allow faster navigational scrolling. Another layout might show every field for a single
record, optimized for data entry.
7
Chapter 1 ■ Introducing FileMaker
The current layout is whichever layout is being displayed in the database window at a given time. This
layout can be changed to another by the user manually selecting a different one or by a script. Figure 1-3
shows a database with two tables, each with a list and entry layout. The window is shown currently
displaying the People Entry layout.
Current Layout
Window
Layouts
Figure 1-3. Illustrating layouts displaying data from their corresponding tables with the window displaying
the current layout
A found set of records is a subset of the total records contained in the table being displayed in a window,
typically after a search. The current record is whichever record from the found set is displayed within a
window showing one record or whichever record is selected within a window showing a list of records.
Scripted Procedures
A script is a stored set of actions that can be automatically performed in response to user activity or on a
schedule. Scripts can generally perform any function with which a user has access.
8
Chapter 1 ■ Introducing FileMaker
www
Request Result
Query Result
Figure 1-4. Showing an overview of the traditional multitiered database architecture with data, interface,
and script as separate but interacting systems
9
Chapter 1 ■ Introducing FileMaker
www
FileMaker File
Figure 1-5. An overview of FileMaker’s integrated database architecture with data, interface, and script
combined in a single file
10
Chapter 1 ■ Introducing FileMaker
While FileMaker’s integrated file structure is most likely inherited from its early development as a
simple, end-user, file-building tool — this characteristic has been retained as it has evolved into the modern
powerhouse it is today. Newer features that allow external data sources, including SQL tables, to be pulled
into a FileMaker database and used as if they were internal, result in a flexibility that provides the best of
both worlds.
Some benefits of this approach include the following:
• Develop the entire database system from within a single, easy-to-use application.
• Databases are files and can be hosted from a central server or a desktop, or used
and shared like self-contained, portable packages just like any other document on a
computer.
• Since a database can include and use external data sources, it is possible to
approximate a multitiered structure. For example, some developers store data tables
in a file separate from the user interface and scripted processes.
11
Chapter 1 ■ Introducing FileMaker
User Experience
Menu Bar
Windows
API
App Resources Default Menus
Preferences
Built-in Script Steps
Plug-ins
Built-in Functions
Database File
Figure 1-6. The component breakdown between the FileMaker application and a database file, grouped by
primary role
12
Chapter 1 ■ Introducing FileMaker
Application Resources
The FileMaker application contains basic resources that interpret settings and information in a database file
to generate a user experience.
Application Resources
Application resources are those things that make up the application programming interface (API) used
to develop custom databases and create the development-user and end-user experience, including the
following:
• Preferences (Chapter 2)
• Plug-ins (Chapter 38)
• Default menus (Chapter 2)
• Built-in functions (Part 3 — or — Chapters 13-24)
• Built-in script steps (Chapters 34 and 35)
• Sharing and networking (Chapters 39-41)
User Experience
The user experience covers what the user sees and how they interact with a database in general use. This
includes the menus (default or custom) and the windows that the application presents to the user in the
interface. The user can then take actions, including these:
• Viewing an interacting with database windows (Chapter 3)
• Creating, opening, and navigating a database file (Chapter 3)
• Working with records (Chapter 4)
• Importing and exporting data (Chapter 5)
Data Structure
The data structure portion of a database contains all the settings that define what is stored in the file, how it
connects, and what functions can be performed on it, and the data itself, including the following:
• Tables (Chapter 7)
• Fields (Chapter 8)
• Data sources, table occurrences, and relationships (Chapter 9)
• Calculation formulas (Chapter 12)
• Custom functions (Chapter 25)
13
Chapter 1 ■ Introducing FileMaker
User Interface
The user interface of a database contains all the settings that define the way things are displayed on layouts
in windows, including the following:
• Layouts (Chapters 27-31)
• Themes and styles (Chapter 32)
• Custom menus (Chapter 33)
• Security settings (Chapter 40)
Scripts
The scripts of a database define the procedures that can be performed automatically or at a user’s request.
(Chapters 34-37).
14
Chapter 1 ■ Introducing FileMaker
Each of these applications has a unique feature set and is either purpose or device specific in its ability
to develop, use, and host databases as listed in Table 1-2.
Table 1-2. The supported devices and fundamental features for each product in the FileMaker family
FileMaker Pro
The standard desktop application is named FileMaker Pro. This application provides general development
features, including the following:
• User Access — provides intuitive front-end access to database features.
• Import/Export — easily exchange data between a FileMaker database and CSV, Tab,
XML, ODBC, Microsoft Excel files, other FileMaker databases, and more.
• Customize — a graphical development environment makes it easy to create custom
databases.
• Reporting — easily build layouts for summarizing data in reports or charts.
• Automate — create scripts to repeat a sequence of actions automatically.
• Sharing — easily share a database with other users by turning on peer-to-peer
networking or uploading a database to a FileMaker Server.
• Secure — create accounts and passwords to limit user acess and activity.
• Integrate — connect external SQL data sources and interact with them; create custom
workflows with scripting languages that allow interaction with other applications
using AppleScript (macOS) and Dynamic Data Exchange (Windows).
15
Chapter 1 ■ Introducing FileMaker
■■Tip To follow along as we explore many of the advanced subjects discussed in this book, you will want a
copy of FileMaker Pro Advanced installed on your computer.
FileMaker Server
FileMaker Server is database-hosting software that is based on industry-standard security technology to offer
user-scalable, secure, and reliable round-the-clock access to databases for authorized users. Its features
include the following:
• Host Databases — dedicated server allows simultaneous, multi-user access to
databases from across a network by users of FileMaker Pro, FileMaker Go, and
FileMaker WebDirect.
• Media Streaming — container field content uses progressive downloading
technology where applicable to begin streaming content for immediate display. For
example, a user will not have to wait for a movie stored in a container field to fully
download before it begins playing.
• Scheduled Events — allow various events to be scheduled for automatic execution
including database backups, run system-level scripts (shell script or batch file), and
run FileMaker script in a FileMaker database.
• Perform Script on Server — databases can opt to have specific scripts run from the
server rather than on a user’s computer to offload tasks and save time.
• Logging — administrators can access event and error logs to troubleshoot problems
and to help optimize database performance.
• Web Direct — authorized users can access databases securely across the Web
through a browser window.
■■Note FileMaker Cloud is another option for hosting databases on the Internet for wide area sharing. The
service combines Amazon Web Services (AWS) and FileMaker Server software (Chapter 39).
FileMaker Go
FileMaker Go is a free iOS app available for both the iPad and iPhone that allows users to access database
resources when away from their desktop computer. With the app, users can access databases stored locally
on their iOS devices or from a FileMaker Server across a network. The app does not include an API, so
databases must be developed on the desktop application prior to use on a device.
16
Chapter 1 ■ Introducing FileMaker
■■Note Accessing a database hosted on a FileMaker Server from FileMaker Go or with FileMaker
WebDirect requires an available user connection license for each connection (Chapter 39: Understanding Client
License Options and Limitations).
FileMaker WebDirect
Although FileMaker offers other options for web hosting, deploying a database on the Web is a lot easier
with FileMaker WebDirect. Once a database has been built with the desktop application, it can be easily
enabled for web sharing and hosted on a FileMaker Server. Users can then access the database through a
web browser. Layouts are automatically rendered in the browser and, except for certain incompatible script
steps and the ability to work in multiple windows, most functionality is identical to that on a desktop or iOS
device.
Summary
In this chapter, we discussed an overview of FileMaker and basic database concepts. We looked at the
big picture history, architecture differences, anatomical overview of components, and we reviewed the
FileMaker product line.
17
CHAPTER 2
In this chapter, we will start exploring the FileMaker Pro Advanced application, covering the following topics:
• Installing and launching FileMaker Pro
• Default windows
• Application preferences
• Default menu bar
• Contextual menus
~/Downloads/
Figure 2-1. The FileMaker Pro Advanced 16 installer disk image, installer disk, and installer window
20
Chapter 2 ■ Exploring the Application
To begin installing the application, click the Continue button on the dialog attached to the installer
window and then on the Continue button on the window itself. Then follow these steps:
1.
Enter your name, organization, and FileMaker license key, then click the
Continue button.
2.
On the software license agreement panel, click Continue and then click the Agree
button to agree to the stated terms.
3.
Choose the installation type and location; the default Standard Install options are
recommended. Then click the Install button.
4.
Authenticate as an administrative user of the computer by either using a Touch
ID or by entering a user name and password, then click the Install button.
5.
Fill out the registration information.
6.
When the installation process is complete, a window will appear notifying you of
this fact. Click the Close button to close and complete the process.
7.
The installer should offer you a choice of what to do with the installer package.
You can Keep the installer in the downloads folder or choose to Move to Trash.
Default Windows
FileMaker has two default windows, one or both of which may appear when the application is launched.
21
Chapter 2 ■ Exploring the Application
Once closed, the FileMaker Get Started window will not reappear. However, it can be manually
opened by selecting the File > Get Started menu.
Launch Center
After the first launch, the default window that FileMaker will open is the Launch Center, shown in Figure 2-4.
This window provides a personalized interface for opening or creating FileMaker database files with
functions including the following:
My Solutions Tab
• Favorite and recently used database files are displayed in a searchable list and are
available for quick opening by double-clicking.
• The Browse button is used to locate, select, and open a database file from any
directory folder or networked FileMaker Server.
• Recently opened databases can be quickly marked as favorites.
• The New button menu allows creation of a new database file.
Hosts Tab
• Favorite and local FileMaker Servers are available in a searchable list.
• The currently selected FileMaker Server’s database files are available in a
searchable list.
• FileMaker Server host computers can be quickly marked as favorites.
The Launch Center window will appear each time you launch the application and can be accessed
manually by selecting the File > Open menu.
For more information about using the Launch Center window, see Chapter 3: Opening an Existing Database.
Application Preferences
The FileMaker application has preferences that control behaviors and allow users to personalize certain
aspects of the experience on their computer. To open the preference dialog, select the applicable menu item:
FileMaker Pro Advanced > Preferences (macOS) or Edit > Preferences (Windows).
Preference settings are separated into five tabs:
• General
• Layout
• Memory
• Plug-ins
• Permitted Hosts
■■Note Some preferences are denoted with the author’s recommendation in parentheses after the description.
General Settings
The General Preference tab, shown in Figure 2-5, contains settings that control the user interface, user name,
and notifications for updates.
23
Chapter 2 ■ Exploring the Application
24
Chapter 2 ■ Exploring the Application
User Name
This setting identifies the name of the user. The behavior varies slightly by platform:
• In macOS, the user name defaults to “System,” which is set in the operating system
preferences; choosing “Other” allows entry of a different user name.
• In Windows, a user name must be entered in the space provided.
Application
Two check boxes control whether FileMaker checks for and notifies the user when an update or new version
is available:
• Notify me when an update is available.
• Notify me when a new version is available.
Layout Settings
The Layout Preference tab, shown in Figure 2-6, contains settings that control certain behavior when a
window is in Layout mode.
Layout Options
• Always lock layout tools — When this box is checked, a selection of a layout tool
will be locked until another layout tool is selected. The default behavior is for the tool
to be released back to the cursor after creating or editing an object (recommended off).
25
Chapter 2 ■ Exploring the Application
• Add newly defined fields to current layout — When this box is checked, any
newly defined field will appear at the bottom of the current layout (recommended off).
• Save layout changes automatically (do not ask) — When this box is checked,
any changes made while in Layout mode will be automatically saved when switching
back to browse mode. If left unchecked, a dialog will confirm whether or not changes
should be saved.
Memory
The Memory Preference tab, shown in Figure 2-7, contains settings that control the limitations of the file cache.
■■Caution Changes to these settings take effect after you quit and re-launch the application.
Plug-Ins
The Plug-In Preference tab, shown in Figure 2-8, contains a list of installed plug-ins and various controls. For
more information on plug-ins, see Chapter 38.
26
Chapter 2 ■ Exploring the Application
Permitted Hosts
The Permitted Hosts Preference tab, shown in Figure 2-9, will contain a list of any host computers whose SSL
certificates cannot be verified. When this happens, FileMaker may notify the user before connecting and, if
permitted, add the host to the list shown on this tab in preferences. To delete a host, once added to the list,
select it and type backspace.
27
Chapter 2 ■ Exploring the Application
FileMaker Pro Advanced File Edit View Insert Format Records Scripts Tools Window Help
Specific menu items may be enabled or disabled depending on various factors. Some menu items are
disabled when:
• No database is open.
• A database script is running or paused.
• A data has a modal window open.
• The user’s current access privileges don’t allow certain functions.
• The user’s current action or context doesn’t allow certain functions.
Similarly, some or all menus and/or items may be completely different when:
• The Get Started screen is open showing a limited menu set.
• A database is in Find mode with a modified menu set (Chapter 4).
• A database is in Preview mode with a modified menu set (Chapter 4).
• A database is in Layout mode with a modified menu set (Chapter 27).
• A modifier key such as Option is held down.
• A database using custom menus is open.
• A developer dialog is open.
This chapter provides an overview of the default menu bar set when viewed with a database open in
Browse mode with no modifier keys held down.
28
Chapter 2 ■ Exploring the Application
• About FileMaker Pro Advanced — opens a dialog window showing the application
version and other information.
• Preferences — opens the preferences dialog window.
• Services — displays any macOS or third-party application services available based
on the current selection.
• Hide FileMaker Pro Advanced — hides the FileMaker application and all open
database windows.
• Hide Others — hides every application except FileMaker.
• Show All — brings all applications to the front, including FileMaker.
• Quit FileMaker Pro Advanced — closes all open databases and quits the
application.
29
Chapter 2 ■ Exploring the Application
File Menu
The File menu, shown in Figure 2-12, contains many file and developer-related functions.
30
Chapter 2 ■ Exploring the Application
• Change Password — opens a dialog that allows the user to change the password
setting for the current account for the current database file.
• Page Setup — opens a dialog for adjusting settings prior to printing.
• Print — opens a dialog for printing the front window.
• Import Records — displays a submenu of import options (Chapter 5).
• Export Records — opens a dialog to begin an export process (Chapter 5).
• Save/Send Records As — displays a submenu of options for saving records from the
front window in Excel, PDF, or Snapshot link format.
• Send — displays a submenu allowing the option to send an email or a Snapshot link
(Chapter 39; Sharing Bookmarks with Snapshot Links).
• Save a Copy As — opens a dialog for saving a copy of the file in various formats
(see details below).
• Recover — opens a dialog to begin a database recovery process (Chapter 6).
31
Chapter 2 ■ Exploring the Application
32
Chapter 2 ■ Exploring the Application
33
Chapter 2 ■ Exploring the Application
Edit Menu
The Edit menu, shown in Figure 2-15, contains a suite of typical editing features that are enabled when
editing the contents of a field.
34
Chapter 2 ■ Exploring the Application
View Menu
The View menu, shown in Figure 2-16, contains functions that control the view of the front database window,
many of which are explained in Chapter 4.
• Browse Mode — switches the mode of the current window to regular database usage:
browsing and editing records.
• Find Mode — switches the mode of the current window to begin a search process.
• Layout Mode — switches the mode of the current window for layout editing
(Chapter 27).
• Preview Mode — switches the mode of the current window to display a print preview
of the current record(s) as formatted on the current layout.
• Go to Layout — displays a submenu of available layouts for the front database to
which the user can navigate with a click.
• View As Form — switches the current window view to form view.
• View As List — switches the current window view to list view.
• View As Table — switches the current window view to table view.
• Status Toolbar — toggles the visibility of the status toolbar at the top of the current
database window.
• Customize Status Toolbar — opens a panel attached to the current window with
toolbar customization options (Chapter 3).
• Formatting Bar — toggles the visibility of the formatting bar between the toolbar
and the content area of the current database window.
35
Chapter 2 ■ Exploring the Application
• Ruler — toggles the visibility of a ruler along the top of the content area of the
current window.
• Zoom In — increases the magnification of the current window by 50%.
• Zoom Out — decreases the magnification of the current window by 50%.
Insert Menu
The Insert menu, shown in Figure 2-17, contains contextually enabled functions for inserting content into the
currently selected field in the current window (Chapter 4, “Insert Functions” section).
Format Menu
The Format menu, shown in Figure 2-18, contains standard text styling functions.
36
Chapter 2 ■ Exploring the Application
Records Menu
The Records menu, shown in Figure 2-19, contains record functions, many of which are explained in
Chapter 4.
37
Chapter 2 ■ Exploring the Application
• Omit Record — excludes the current record from the found set in the current
window.
• Omit Multiple — displays a dialog allowing the entry of a number indicating how
many records to exclude from the current found set, starting from the current record.
• Modify Last Find — enters find mode with the last find criteria re-created.
• Saved Finds — displays a submenu containing commands to save the current find,
edit saved finds or perform a recent or saved find.
• Sort Records — opens a dialog allowing the user to specify a sort order for the
records in the found set of the current window.
• Unsort — reverts the sort order of the records in the found set of the current window
to their creation order.
• Replace Field Contents — opens a dialog allowing the user to specify criteria to
change the value in the current field for every record within the found set.
• Relookup Field Contents — refreshes the current field’s contents for every record
in the found set based on its lookup settings in field definitions (Chapter 8).
• Revert Record — closes the current record without saving any changes.
Scripts Menu
The Scripts menu, shown in Figure 2-20, provides access to the Script Workspace window and displays a list
of individual scripts that have been configured to appear here (Chapter 34).
Tools Menu
The Tools menu, shown in Figure 2-21, is only available in FileMaker Pro Advanced and contains the
following commands:
• Script debugging features (Chapter 36)
• Access to the data viewer window (Chapter 36)
• Custom menu setup (Chapter 33)
• Database design report (Chapter 41)
• Developer utilities (Chapter 34)
38
Chapter 2 ■ Exploring the Application
Window Menu
The Window menu, shown in Figure 2-22, contains many window-related functions. For more information,
see Chapter 3.
• New Window — opens a new window defaulting to the same size, layout and found set
as the current window.
• Show Window — displays a submenu of all windows that are currently hidden that
can be brought to the front with a click; the selected window will be repositioned on
screen if it is hidden off-screen.
• Hide Window — hides the current window.
• Minimize Window — minimizes the current window into the macOS dock.
• Tile Horizontally — repositions all open windows horizontally across the screen.
• Tile Vertically — repositions all open windows vertically across the screen.
• Cascade Windows — repositions all open windows in a cascade, one overlaping
the next.
• Bring All To Front — brings all windows to the front, although some may remain
off-screen.
39
Chapter 2 ■ Exploring the Application
Help Menu
The Help menu, shown in Figure 2-23, contains help and other application related functions.
Contextual Menus
A contextual menu is a pop-up menu that appears within a specific context of a graphical user interface
when the user right-clicks the cursor on an area possessing one, like the one shown in Figure 2-24. These
menus can increase the speed of accomplishing certain tasks. A user can quickly locate and trigger the
command they are looking for directly from the object or location upon which the command will act, much
faster than locating the command in the more cluttered menu bar.
40
Chapter 2 ■ Exploring the Application
FileMaker has numerous different contextual menus, summarized here into four categories:
• Fields
• Record content area
• Web viewer
• Window
41
Chapter 2 ■ Exploring the Application
42
Chapter 2 ■ Exploring the Application
Summary
In this chapter, we discussed the basics of the FileMaker Pro application, including its preferences and
default Browse mode menus.
43
CHAPTER 3
Over the next three chapters, we will focus on the user experience of working in a database file. This will
provide a familiarity with interface and general FileMaker concepts. Readers already familiar with the basic
appearance and behaviors of FileMaker may can skip ahead but may find a review of these topics useful.
For this process, we will create a database from a starter solution provided by FileMaker. It is important
to note that the window of the solution we create contains both default window resources and custom
sample database layouts. Although that solution is created by FileMaker, Inc. and does provide a nice
example for this orientation tour, it is not necessarily indicative of how a custom solution will or should be
designed. In later chapters, we will create a new database and discuss how to develop a custom solution with
design custom layouts.
In this chapter, we will discuss topics such as the following:
• Using a starter solution
• Defining the database window
• Exploring the window header
• Managing multiple windows
• Opening an existing database
Advanced solutions
• Assets
• Contacts
• Content management
• Estimates
• Event management
• Expense report
• Inventory
• Invoices
• Meetings
• Personnel records
• Product catalog
• Projects
• Research notes
• Resource scheduling
• Tasks
• Time billing
46
Chapter 3 ■ Exploring a Database Window
Figure 3-1. The default window of the new database created from the Contacts starter solution template
47
Chapter 3 ■ Exploring a Database Window
Browse Mode
Browse mode, the default and most common window state, is used to view and perform data entry
interactions with records. In this mode, the content area of the window represents the actual data stored in
the current layout’s table. A user can create, view, edit, delete, duplicate, sort, and omit records, click buttons
and other controls, and run scripts. For more information on working with records, see Chapter 4.
Find Mode
Find mode is a window state in which the layout transforms to display a blank record where the user enters
criteria used to search for a desired set of records. In this mode, a record is considered a request. Users
can interact with requests just as they do with records, but requests only exist temporarily as a means of
collecting the criteria prior to performing the search. For more information on searching for records, see
Chapter 4.
Preview Mode
Preview mode is a window state that displays the current layout as a preview of how it will appear on a
printed page. The layout will look generally the same except that fields will not be editable, and objects
may slide and compress, summarize, and change formatting depending on the layout settings. For more
information on previewing and printing records, see Chapter 4.
48
Chapter 3 ■ Exploring a Database Window
Layout Mode
Layout mode is a window state that displays the current layout in a design mode. This allows users with
development access to edit which fields and controls will appear in Browse, Find, and Preview modes and
configure their formatting and functional settings. For more information on designing layouts, see Chapters 27-31.
Form View
The Form view format displays records one record at a time as a form for data entry. When in this view, the
user must navigate forward or backward using the navigation controls in the toolbar to see other records
instead of scrolling through a list within the window frame.
List View
The List view format displays all the records in the current found set as a continuous list, repeating the layout
elements once for each record. When in this view, the user can scroll up or down to see other records.
Table View
The Table view format displays all the records in teh current found set in a spreadsheet-style arrangement of
columns and rows with no rich interface formatting.
■■Note For additional information about Content Views see Chapter 28, “Planning Layouts”.
■■Note Every toolbar control is connected to basic FileMaker commands and is automatically enabled or
disabled based on the respective command’s representation and enabled in the menu bar. See Chapter 33,
“Exploring the Link Between Commands and Menus.”
1 2 3
4 5 6 7 8
Figure 3-2. The default status toolbar of a database window in Browse mode
The Browse mode toolbar can be divided into the following areas:
1.
Record navigation controls
2.
Function buttons
3.
Quick search field
4.
Layout menu
5.
View buttons
50
Chapter 3 ■ Exploring a Database Window
6.
Preview button
7.
Formatting bar button
8.
Edit layout
2 3
■■Caution The record navigation arrows are sometimes confused with general navigation arrows like those
in a web browser. Instead of navigating backwards and forwards to different layouts, these buttons navigate to
records within the found set on the current layout.
Function Buttons
The function buttons region of the toolbar, shown in Figure 3-4, includes controls to manage records and
share a database.
51
Chapter 3 ■ Exploring a Database Window
Figure 3-5. The default toolbar Quick Search field in Browse mode
Layout Menu
The lower, non-customizable level of the toolbar starts with the Layout menu on the left. In Browse mode,
this pop-up menu displays a list of layouts that have the Include in Layouts Menu option selected checked
(Chapter 28). When a user selects a layout from the list, the window view switches to display the selected
layout.
Layout navigation is also available from the View > Go To Layout menu.
View Buttons
Next in the lower portion of the status toolbar are three buttons that will change the current window’s view
to that selected. The view buttons that are enabled here are controlled by the current layout’s view settings
(Chapter 28).
Preview Button
The Preview button will switch the window into print preview mode (Chapter 4).
52
Chapter 3 ■ Exploring a Database Window
Figure 3-6. The customize toolbar panel attached to the Contacts database window in Browse mode
53
Chapter 3 ■ Exploring a Database Window
■■Note Don’t be afraid to experiment. Later, we will review how to restore the entire toolbar to its default set
of controls.
Formatting Bar
The formatting bar is a thin bar that contains text-formatting controls for quick access. Not visible by default,
this bar, shown in Figure 3-7, will appear between the status toolbar and the window’s content area when
the View > Formatting Bar menu is selected or the icon on the lower right of the toolbar is clicked.
54
Chapter 3 ■ Exploring a Database Window
When a user is editing a text field in Browse mode, the following controls will become enabled in the
formatting toolbar, providing access to the following formatting settings of a field’s text:
• Font
• Font style
• Font size
• Font color
• Text alignment
When a window is in Layout mode, the formatting bar contains a few additional options for object fill
color as well as line style, thickness, and color.
Window Ruler
A FileMaker window can display a horizontal ruler when in Browse mode, shown in Figure 3-8. To toggle the
visibility of this ruler, select the View > Ruler menu.
Figure 3-8. A window with the Browse mode ruler visible between the toolbar and the content area
In Browse mode, the ruler doesn’t offer much value when displayed across the entire window.
However, when the cursor focus is inside a text field, the ruler scales down to the size of that field, as shown
in Figure 3-9, and will then display any tabs set for that field and allow margin adjustments (for that field’s
content for current record only).
55
Chapter 3 ■ Exploring a Database Window
When a window is in Layout mode, the ruler option displays a horizontal and vertical ruler that is useful
when designing interfaces (Chapter 31).
The units can be changed within the ruler’s contextual menu. The available units are:
• Inches
• Points
• Centimeters
56
Chapter 3 ■ Exploring a Database Window
Once the window has appeared, the user can work within it as they could in the original window.
The window can be moved and resized for side-by-side viewing. Each window has its own context so you
can change layouts and work with different record sets.
Closing a Window
A window can be closed just like any document window, using any of the following methods:
• Select the File > Close Window menu item.
• Click the red dot in the upper-left corner of the window.
FileMaker requires one window to remain open as a representation of the database file. If the last
remaining window for a database is closed, the file itself will be closed.
Figure 3-10. The list of open windows at the bottom of the Window menu
57
Chapter 3 ■ Exploring a Database Window
■■Note In some cases, a database may open with the default window immediately hidden. This can be
intentionally done by a script or when a file is automatically opened in the background because its fields or
scripts are used by another open file.
Minimizing a Window
A database window can be minimized into the toolbar by any of these methods:
• Select the Window > Minimize Window menu item.
• Click the orange dot in the upper-left corner of the window.
Minimizing will cause the current window to shrink down into an icon in the dock; however, FileMaker
will continue to list it as an open window rather than a hidden window. Clicking the window icon in the dock
or selecting it from the bottom of the Window menu will cause it to reappear at its former location and size on
screen, in front of any other windows.
58
Chapter 3 ■ Exploring a Database Window
• Select the File > Open Recent menu item to access a submenu of recently opened
databases.
• Select the File > Open Favorite menu item to access a submenu of favorite
databases.
• Select the File > Open Remote menu item to open the Launch Center Host’s tab
and access databases hosted on a FileMaker Server.
To open a file not already displayed in the window, click the Browse button on the lower left to access
an Open File dialog, shown in Figure 3-13. Navigate to the directory containing the desired file, select it and
then click the Open button.
59
Chapter 3 ■ Exploring a Database Window
Summary
In this chapter, we created a new database from a starter solution template and discussed the basics of a
FileMaker Pro window.
60
CHAPTER 4
A record is a collection of values that make up a single entry in a table. Similar to a row of a spreadsheet, each
record contains field values that together represent the properties of one entity of the type after which a table
is modeled. For example:
• In a Contacts table a record would represent one person.
• In a Projects table a record would represent one job.
• In an Inventory table a record would represent one product.
Most of a user’s work in a database will be spent interacting directly with records, from within the
content area of a window. Records can be created, edited, deleted, omitted, searched, exported, imported,
printed, and viewed.
In this chapter, we will focus on how a user interacts with records, covering topics such as the following:
• Entering data
• Managing records
• Searching for records
• Working with found sets
• Printing
■■Note Throughout this chapter, we will continue working in the Contacts database we built in Chapter 3
using FileMaker’s starter template.
Entering Data
Data entry tasks are performed while a window is in Browse mode and a record is opened into an editable
state. Data can be entered, edited, and formatted in whatever field has current focus on the current open
record. Once finished, the record is closed and changes are either reverted or committed.
Opening a Record
Once a user has identified a record they want to edit, they must open it. If a user begins typing while viewing
a record before opening it, an error dialog indicating this fact will appear.
Opening a record means that the record is activated into an edit state in which the fields are no longer
simply displaying information, they are activated and ready for data input.
To open the current record for data entry, perform any one of these steps:
• Click into any editable field.
• Type the Tab key.
• Run a script or click a button that uses the Open Record/Request script step.
Once a record is open for data entry, it may appear like it does when viewed. However, differences in
appearance between viewing and editing states will depend on the choices made by whoever developed the
database. It’s a good practice for developers to program some visual change to help a user clearly see that
the record is opened and ready for input. For example, the field borders might become visible or change
thickness or color. Unfortunately, the Contact starter solution from FileMaker doesn’t provide such an
indication and instead only makes clear that a single field has focus and is ready to accept input.
Once again, other formatting changes may occur depending on the theme used or the formatting
choices made by the developer of the layout.
■■Note: A keys that allow navigating to the next object in the tab order can be customized with the Go to next
object setting (Chapter 29).
62
Chapter 4 ■ Working with Records
Typing
The most basic method of entering data into any data entry field (except containers) is by typing on the
keyboard once field focus has been established.
■■Caution Undo does not include reversing actions such as record deletion.
Insert Functions
The Insert menu and Insert submenu of a field’s contextual menu make available several functions for
quickly inserting various content into fields such as pictures, files, and text. Each of these menu items are
contextually enabled depending on the data type of the field being edited and based on the enabled status of
a container field (Chapter 29).
63
Chapter 4 ■ Working with Records
• Insert Picture — select an image file that will be inserted into a current container
field, where it will be displayed as an image.
• Insert Audio/Video — select an audio or video file that will be inserted into
a current container field. This option is only available if the container field is
configured to allow interactive content; otherwise use Insert File.
• Insert PDF — select a PDF file that will be inserted into a current container field.
This option is only available if the container field is configured to allow interactive
content; otherwise use Insert File.
• Insert File — select any file that will be inserted into a current container field,
where it will be displayed as an enclosed file icon.
• Current Date — insert today’s date into the current text or date field.
• Current Time — insert the current time into the current time field or the current
timestamp into the current timestamp field.
• Current User Name` — insert the current user name into the current field.
• From Index — displays a dialog showing a list of unique values for all records for the
current field. The user can double-click on any of these values to automatically insert
it into the field for the current record.
• From Last Visited Record — inserts the value of the current field from the last
record viewed into the current record.
Mouse Clicks
When a field is configured with a control style other than Edit Box (Chapter 30) entering or selecting data
may be require or optionally be performed with mouse clicks. For example, a check-box style formatting
requires a click onto boxes next to the desired value(s) while a calendar style formatting gives the option of
entering a date by selecting one from a graphical calendar.
Closing a Record
Once a user is finished editing, the record needs to be closed by either committing or reverting the changes.
Committing a record closes the record while saving all changes made during the editing session.
A record can be committed by:
• Clicking on the layout outside of any field and away from any other object.
• Typing the Enter key.
• Navigating forward or backward to another record.
• Running a script or clicking a button that uses the Commit Records/Requests script step.
64
Chapter 4 ■ Working with Records
FileMaker will perform any data entry validations prior to committing a record and will halt and report
problems if any are detected.
Reverting a record closes the record while omitting all changes made during the editing session.
A record can be reverted by:
• Selecting the Records > Revert Record menu.
• Running a script or clicking a button that uses the Revert Records/Requests script step.
Managing Records
Users can create, delete, and duplicate records.
Deleting a Record
The current record in the front window can be deleted by using one of these methods:
• Select the Record > Delete Record menu item.
• Select Delete Record from the record contextual menu.
• Clicking the Delete Record icon in the toolbar.
• Running a script or clicking a button that uses the Delete Record/Request script step.
FileMaker will confirm that the user wants to continue with the deletion by presenting a warning dialog,
shown in Figure 4-2. If the user confirms the deletion by clicking the Delete button, the record will be
permanently deleted from the table. Clicking the Cancel button will dismiss the dialog without any further
action taken.
65
Chapter 4 ■ Working with Records
Figure 4-2. The delete record warning dialog presented to the user prior to deleting a record
■■Note A user can bypass this warning dialog and instantly delete a record by holding Option (macOS) or
Shift (Windows) while selecting the Delete Record option! While this feature may be a useful tip for power
users, it can be dangerous for new users and perhaps shouldn’t be shared with everyone. Custom Menus
(Chapter 33) can be used to suppress this feature.
Figure 4-3. The delete all records warning dialog presented to the user prior to deleting all records in the
found set
Duplicating a Record
The current record in the front window can be duplicated using one of these methods:
• Select the Record > Duplicate Record menu item.
• Select Duplicate Record from the record contextual menu.
• Running a script or clicking a button that uses the Duplicate Record/Request script
step.
66
Chapter 4 ■ Working with Records
Once initiated, FileMaker will immediately create a duplicate of the current record, that is open and
ready for entry with focus on the first field in the tab order.
Figure 4-4. The quick find search field in the status toolbar
67
Chapter 4 ■ Working with Records
Figure 4-5. The dialog notification of no matching records for the quick find criteria entered
68
Chapter 4 ■ Working with Records
Figure 4-6. The find matching records function selected in the field contextual menu
Each of these three functions will instantly perform a predefined type of search for records that match
the value in the current field:
• Find Matching Records — This function will perform a new find in the current field
for the value in that field on the current record.
• Constrain Found Set — This function will narrow the current found set of records to
only those within the found set that match that field value for the current record.
• Extend Found Set — This function will expand the current found set of records to
include other records that match that field on the current record.
■■Note The behavior for constraining and extending a found set from the contextual menu varies slightly
from that performed by the same options available in the menu bar and script steps.
69
Chapter 4 ■ Working with Records
70
Chapter 4 ■ Working with Records
Navigation Controls
At the top left of the toolbar are the navigation controls that appear and function exactly as they do in Browse
mode with one important difference; they refer to and control find requests rather than records. A find
request is a record-like version of the current layout that is used to enter search criteria.
Function Buttons
The following buttons are included in the default Find mode toolbar:
• New Request — creates a new find request for entering alternative criteria.
• Delete Request — deletes the current find request if it is not the only find request.
• Perform Find — performs the find, based on the criteria entered in the find
request(s) and returns to browse mode with a found set of the results.
• Cancel Find — aborts the find process and returns the window to Browse mode
displaying the previous found set.
On the top right of the Find mode toolbar, is the Saved Finds menu button, which makes available the
following functions:
• Save Current Find — saves the current find criteria so that the identical search
process can be easily repeated in the future.
• Edit Saved Finds — opens the Edit Saved Finds dialog.
• Saved Finds — displays a list of saved finds, which can be performed with a click.
• Recent Finds — displays the last 10 recent finds, which can be performed
with a click.
• Clear All Recent Finds — clears all the recent finds.
71
Chapter 4 ■ Working with Records
■■Caution Saved finds only store the criteria and not the resulting found set of records! Each time a find
is performed, that criteria is applied in searching every record in the table, including those that may not have
existed at the time the find was saved.
Layout Menu
The lower, non-customizable level of the Find mode toolbar starts with the Layout menu, which operates
like it does in Browse mode. This pop-up menu displays a list of layouts that have the Include in Layouts
Menu option selected (Chapter 28).
When a user selects a layout from the list the window view switches to display the selected layout
while maintaining Find mode. This can be useful if the user wishes to create a find using multiple fields for
the same table that are spread over several different layouts. However, if the user switches to a layout for
a different table, criteria entered in layouts representing other tables will be ignored and the find will be
performed based on the context and criteria entered for the last table.
View Buttons
Next on the lower portion of the Find mode toolbar are three buttons that will change the current window’s
view, like they do in Browse mode (Chapter 3). The views that are enabled are controlled by the current
layout’s view settings (Chapter 28).
72
Chapter 4 ■ Working with Records
Figure 4-9. The customize toolbar panel attached to the Contacts database window in Find mode
73
Chapter 4 ■ Working with Records
Operator Description
= Use in front of a value to match a whole word within the field. Entered by itself, it will match
records where that field is empty.
== Use in front of a value to match an entire phrase within the field.
! Use to find any records where the field has one or more duplicate values on other record(s).
< Use to find numeric or text values that are less than the value entered after the symbol.
≤ Use to find numeric or text values that are less than or equal to the value entered after the
symbol.
> Use to find numeric or text values that are greater than the value entered after the symbol.
≥ Use to find numeric or text values that are greater than or equal to the value entered after the
symbol.
… Use to find a range of values. For example, entering “1/15/2017…1/30/2017” will find all
records where the field contains a date including or between the two dates entered.
// Use to find records where the field contains today’s date.
? Use to find records where the field contains an invalid date or time.
@ Use to find records where the field contains any one character or combined string of any
character. For example, “@” will find “D” or “T” and “@@@@” will find “Door” or “Test.”
(continued)
74
Chapter 4 ■ Working with Records
Operator Description
# Use to find records where the field contains any one number or combined length of any
number. For example, “#” will find “3” or “8” and “##” will find “33” or “81.”
* Use in place of a character to create a search pattern. For example, “1/15/*” will find any
records where the field contains a date of January 15 for any year.
\ Use to escape the next character. This can be useful when searching for a literal operator by
treating the operator as part of the search criteria and not as an operator. For example, to
search for any records where the field contains a quote symbol, enter \”.
“” Use to match the phrase typed between the quote marks.
*“” Use to match the phrase typed between the quote marks. In a field containing a lot of text.
~ Use to perform a relaxed search in Japanese text.
Figure 4-11. The navigation area showing two requests in Find mode
75
Chapter 4 ■ Working with Records
The navigation controls work just as they do in Browse mode, except you are clicking or scrolling back
and forth between find requests instead of actual records.
In a Contacts file, to search for records that contain either “NY” or “OH” in a State field, follow these
steps:
1.
Enter Find Mode.
2.
Type “NY” into the State field.
3.
Create a new find request.
4.
Type “OH” into the State field.
5.
Click the Perform Find button or type the Enter key.
The results of this find should be all contacts that work in either state blended into a found set in the
order in which they were created.
■■Note When creating many find requests, FileMaker will eventually present a dialog reminding you that you
are in Find mode. This is designed as a warning to avoid a situation where a user might mistakenly assume they
are creating records when they are really creating find requests since the views and process are so similar.
■■Caution Unlike when deleting records, deleting a find request happens instantly without a warning dialog.
76
Chapter 4 ■ Working with Records
Performing a Find
Once all the criteria are entered into the appropriate fields, the search process can be performed by any of
these methods:
• Type the Enter key.
• Click the Perform Find button in the toolbar.
• Select the Requests > Perform Find menu.
Once initiated, FileMaker will search the current table and display the results. If there are no results, a
dialog will be presented notifying the user of this fact with an option to modify the find or cancel the process.
If results are found, they will be listed in creation order as the current found set in the window.
77
Chapter 4 ■ Working with Records
For example, if viewing a found set of contacts generated by searching for a Work State of “NY”, this
result can be extended to include contacts that have a Work State of “OH,” by following these steps:
4.
Enter find mode.
5.
Type “OH” into the Work State field.
6.
Select the Request > Extend Found Set menu.
The resulting found set should consist of a list of records with a Work State of “NY” or “OH” in
creation order.
78
Chapter 4 ■ Working with Records
7.
Create a new find request and click the “Omit” option in the toolbar.
8.
Enter “Columbus” in the Work City field.
9.
Perform the find.
Saving a Find
The last executed find can be saved by one of these methods:
• Select the Records > Saved Finds > Save Current Find menu item while in
Browse mode.
• Select Save Current Find from the menu on the Find toolbar icon while in
Browse mode.
• Select Save Current Find from the menu on the Saved Finds toolbar icon after
entering find criteria in Find mode.
Each of these will open the current or last find in a Specify Options for the Saved Find dialog,
shown in Figure 4-12.
Figure 4-12. The Specify Options for the Saved Find dialog
The dialog allows the user to edit the name and criteria of the find being saved.
79
Chapter 4 ■ Working with Records
In this example, a better name that includes the table and field name and the criteria could take the
following form:
80
Chapter 4 ■ Working with Records
The dialog displays a list of all finds stored within the current database file and the following
function buttons:
• New — creates a new, empty find and opens it in the Specify Options for the Saved
Find dialog.
• Edit — opens the selected find in a Specify Options for the Saved Find dialog.
• Duplicate — creates a duplicate of the selected find.
• Delete — deletes the selected find.
• Cancel — closes the dialog without saving changes.
• OK — saves changes and close the dialog.
81
Chapter 4 ■ Working with Records
The dialog displays a list of the requests that make up one stored find. Each line represents a single find
request containing one or more criterion. These can be managed using the following function buttons:
• New — creates a new, empty find request for the current find in an Edit Find
Request dialog, shown in Figure 4-15.
5
3
7
8
4
9
6 10 11
82
Chapter 4 ■ Working with Records
■■Tip To avoid confusion, especially for complex finds, create the find in the interface and then save it and
look at the request in this dialog. That will help you understand how to construct a find in the dialog.
83
Chapter 4 ■ Working with Records
Figure 4-16. The different information displayed in the navigation area when viewing all records or a found set
When navigating to other layouts that display records for the same table within the same window, the
found set remains constant until the user or a script changes it. Every table within a window has its own
found set. When using multiple windows, each window has its own context and, therefore, a unique found
set for each table contained in the file.
84
Chapter 4 ■ Working with Records
Omit Record
The Omit Record command will move the current record from the found set to the omitted set. This helps to
fine-tune the results of a find without the need to perform a new, more complex search.
Omit Multiple
The Omit Multiple command displays a dialog for the user to enter a number indicating how many
records they wish to move from the found set to the omitted set, starting from the current record. This helps
to fine-tune the results of a find like the single-record Omit command but in larger record chunks.
For example, if the user is viewing the first record of a found set of 100 records and they choose this
command and enter the number 10, the first 10 records will be omitted leaving the remaining 90 records as
the new found set. However, if they are viewing record 50 of 100 and do the same thing, then record 50–59
will be omitted leaving records 1-49 and 60-100 as the new reduced found set.
85
Chapter 4 ■ Working with Records
1 2
4
5
7 8 9
86
Chapter 4 ■ Working with Records
4.
Reorder based on summary field— This check box and associated Specify
button allows the selection of a summary field that will be used as a secondary sort
to reorder records based on a field value that is first sub-summarized by another
sort field. First add the field that is used by a summary field. Then, with that field
selected, check this box and select the summary field to re-sort the summarized
records. When used, a small document icon will appear in place of the sort
direction indicator next to the field in the sort order.
5.
Override field’s language for sort — This check box and associated
pop-up menu allows the selection of a different language to control indexing
for the sort for text fields.
6.
Keep records in sorted order — When this box is checked, changes to the
values of sort fields on records will not automatically update the sort order.
Uncheck this box to have the sort dynamically update after any change is
committed.
7.
Unsort — This button will unsort the found set of records and close the dialog.
8.
Cancel — This button will close the dialog without modifying the sort order of
the found set.
9.
Sort — This button will re-sort the records in the found set and close the dialog.
The sort status of records will be indicated in the record navigation area of the toolbar as shown
in Figure 4-18. If the Sort dialog is reopened while records are already sorted, it will display the fields
controlling the current sort order.
Figure 4-18. The record count with an indication that the records are currently sorted
87
Chapter 4 ■ Working with Records
88
Chapter 4 ■ Working with Records
89
Chapter 4 ■ Working with Records
The features available should be familiar to anyone with minimal computing knowledge and word-
processor experience so an exhaustive tutorial should be unnecessary. The following summarization of the
available features accessible through the dialog should suffice:
• The text to search for is typed into the Find what field.
• Optional replacement text is entered into the Replace with field.
• The Direction pop-up menu offers the choice of moving through the fields on a
record and the records in a found set forwards or backwards.
• Selecting the Match case check-box will force the find process to only consider a
match when the case of text in the field matches what is typed in the Find what field
exactly.
• Selecting the Match whole words only check box will force the find process to only
consider a match when the text in a field contains the entire, separate word(s) typed
into the Find what field.
• The Search across radio buttons instructs the function whether it should search all
records in the found set or just the current record.
• The Search within radio buttons instructs the function whether it should search all
fields on the layout or just the current field.
• The Find Next button will locate and highlight the next instance of the text from the
Find what field in the current field, next field, or next record, depending on the other
settings in the dialog.
90
Chapter 4 ■ Working with Records
• The Replace & Find button will either locate the first instance of a match, if one
has not yet been made, or replace the currently highlighted matched text with the
replacement text and then locate the next instance of a match.
• The Replace button will perform the replace function if a find has already selected
a matching instance of the search text. Afterwards, the cursor remains immediately
after the replaced text.
• The Replace All button will replace all matching instances of the search text based
on the settings in the dialog.
• The Close button will close the Find/Replace dialog.
The other options only available in the Edit > Find/Replace submenu are the following:
• Find Again — will repeat the last Find command, stepping to the next instance of a
match if the command is already in process.
• Replace & Find Again — will either perform the first find match or, if one is already
selected, perform the replace and move to the next instance of a match.
• Find Selected — will find the next instance of the selected text using the last
settings from the dialog but without opening it.
Spell Checking
FileMaker has a fully featured spell checker that can check and correct a selected piece of text, the contents
of a field, every field on a record or field(s) for all records within the found set.
91
Chapter 4 ■ Working with Records
Figure 4-21. The spelling features at the top of the text contextual menu when selecting a questionable word
92
Chapter 4 ■ Working with Records
Printing
The contents of a database window can be previewed and/or printed using one of several commands
available through the standard Print dialog window. The print settings and page setup configuration for the
window can be configured manually through standard Page Setup and Print dialogs by a user, directly with
a script, or a combination of the two.
While layouts can be designed specifically for printing (Chapter 28), any layout can be printed.
Page Setup
A database file’s page setup options can be configured while in Browse, Preview, or Layout mode, using one
of the following two methods:
• Selecting File > Page Setup to open the Page Setup dialog, shown in Figure 4-22.
• Running a script or clicking a button that uses a Page Setup script step.
The Page Setup dialog is a standard operating system dialog that allows control of how layouts in the
file will behave when printing.
93
Chapter 4 ■ Working with Records
94
Chapter 4 ■ Working with Records
Navigation Controls
At the top left of the toolbar are the navigation controls that appear and function like how they do in Browse
mode with one important difference: they refer to and control pages rather than records. At first, the page
count will be displayed as a question mark because the entire document has not yet been rendered. Clicking
through pages or scrolling to the end will force the page count to be updated.
Function Buttons
The following function buttons are included in the default Preview mode toolbar:
• Save as Excel — opens a Save Records as Excel dialog that allows the user to
configure how the records displayed will be exported into an
excel format.
• Save as PDF — opens a Save Records as PDF dialog that allows the user to
configure how the pages displayed will be saved as a PDF file.
• Print — opens the Print dialog.
• Page Setup — opens the Page Setup dialog.
Layout Menu
The lower, noncustomizable level of the Preview mode toolbar starts with the Layout menu, which operates
the same as it does in Browse and Layout modes.
95
Chapter 4 ■ Working with Records
Figure 4-24. The customize toolbar panel attached to the Contacts database window in Preview mode
96
Chapter 4 ■ Working with Records
The dialog is a standard operating system dialog and shouldn’t need much elaboration. The FileMaker
options available are the following:
• Number pages from — Enter a number in this field to indicate the page number of
the first page.
• Print: Records being browsed — Selecting this radio button will indicate that
every record in the found set should be included in the printout.
• Print: Current record — Selecting this radio button will indicate that only the
current record should be included in the printout.
• Print: Blank record, showing fields — Selecting this radio button will indicate
that the layout should be printed with record data. The adjacent pop-up menu
allows the selection of formatting options for fields: as formatted, with boxes, with
underlines, or with placeholder text.
Clicking the Print button will perform the print operation as configured in the dialog and close the dialog.
Summary
In this chapter, we discussed numerous subjects pertaining to how a user interacts with records.
97
CHAPTER 5
Transferring Data
FileMaker supports many file types and offers various options when transferring data in or out of a database.
These functions can all be performed manually or automatically with scripts (Chapter 35).
In this chapter, we are concerned only with importing and exporting manually.
Table 5-1. The file types FileMaker supports for exporting and importing data
In addition to the file types above, FileMaker supports importing from several different sources
including:
• A folder of pictures, movies, or text.
• A XML file contain data with an accompanying XSL style sheet.
• An ODBC data source.
100
Chapter 5 ■ Transferring Data
Figure 5-1. Download link for free sample data for testing from briandunning.com
The file should open in Excel and display 500 rows of sample data in the following twelve columns:
• First_name
• Last_name
• Company_name
• Address
• City
• County
• State
• Zip
• Phone1
• Phone2
• Email
• Web
Importing Records
The Import Records process will create or update records in the current layout’s table from a file of any of
the supported type listed at the start of this chapter.
To begin an import:
1.
Open the database into which records will be imported. For the examples in this
chapter, open the Contacts database we have been working with.
2.
Navigate to the desired layout into which the records will be imported. Since the
Contacts database has only one table, any layout is fine.
3.
Select the File > Import Records > File menu item to open a Choose File
dialog, as shown in Figure 5-2.
101
Chapter 5 ■ Transferring Data
102
Chapter 5 ■ Transferring Data
Once the dialog is configured and the OK button is clicked, FileMaker will perform these functions
automatically:
• Create a new table named the same as the selected incoming file.
• Create a field for every column of data in that file.
• Create a layout with the specified name, assigned to that table, set to table view and
with every field displayed.
• Create a script with the specified name that will go to that layout, delete every record,
and import the records from the file thereby refreshing the data.
This dialog remembers the path of the source data and has three configurable options:
• Don't import first record — If the first row of data in the source file contains field
names instead of data content, check this box.
• Layout Name — specify the name for the new layout that will be created. The default
will be the name of the source file.
• Script Name — specify a name for the new script that will be created. The default
will be the name of the source file.
When this option is used and the import finishes, you will need to rename fields, reconfigure the layout,
and customize the script to suit your needs and preferences.
103
Chapter 5 ■ Transferring Data
Performing an Import
To continue with a manual import, point the Choose File dialog at the us-500.csv file on the Desktop and
click the Open button. This will open the Import Field Mapping dialog, shown in Figure 5-4.
The field-mapping dialog is used to instruct FileMaker where the incoming data should flow. The dialog
allows the selection of a table and control over various import behaviors.
104
Chapter 5 ■ Transferring Data
While this universal menu will list other related and unrelated tables that exist in the database, these
options will remain disabled since you can only import into the current layout’s table (unless you use the
option to create a new table).
The target menu contains two additional options:
• New Table — selecting this option will configure the dialog to automatically create
a new table during the import and flow the data into it. The field names will default
to a sequential generic list, f1, f2, f3, etc. Unless you check the Don't import first
record check box on the lower left indicating that the values of the first incoming
record should be used as the field names.
• Manage Database — selecting this option or clicking the button of the same name at
the bottom of the dialog will open the developer dialog for defining tables, fields and
relationships (Chapters 7-9). This allows you to create a new table with custom field
names or to add fields to an existing table. Unfortunately, any new table you create
will not be available from the menu unless you cancel the import process, create a
layout for the table, and restart the process while that table is current. But this can be
a great way to quickly add a new field to the current table.
105
Chapter 5 ■ Transferring Data
Mapping Fields
The central part of the import dialog is used to align fields from the source file on the left with fields from the
database on the right.
The Arrange By pop-up menu located below the field list, shown in Figure 5-6, is used to automatically
reorder the list of target fields to any of the predefined list of options. These options can sometimes help to
quickly match fields by name when the lists are more similarly matched than our example. In the case of our
sample data, they do not.
Figure 5-6. The options available for arranging the list of target fields
When the two lists of field names are not closely matched, target fields must be dragged to align them
correctly with their corresponding source field. The target fields can be dragged up or down by grabbing the
small black two-sided arrow icon just to the left of the field name, shown in Figure 5-7.
Figure 5-7. The two-sided arrow icon is used to drag a target field up or down in the list
When a field is dropped somewhere in the list, the two fields — the one dragged and the one it is
dragged onto — exchange positions. Continue dragging the fields until they align to the correct fields, shown
in Figure 5-8.
Figure 5-8. A final arrangement of properly aligned source and target fields
106
Chapter 5 ■ Transferring Data
The icon in the middle column indicates how the fields are mapped to each other and, therefore,
how they will behave during the import. There are four possible icons that will appear here depending on
the import action selected. Each is labeled in the Field Mapping key on the right of the dialog layout. For
the default Add new records import action, the icon should be the Import this field arrow shown in
Figure 5-9.
If you see two square dots as shown in Figure 5-10, this is the Don’t import this field icon and
indicates that the adjacent field will not be imported. To include it, click the icon to toggle it until it displays
the arrow.
A target field displayed with gray coloring indicates a field that can’t receive data, such as a calculation
or summary field. Clicking the icon for these will toggle to the Target cannot receive data icon shown in
Figure 5-11.
Once the fields are lined up and the icons set, optionally select the Don't import first record check
box to indicate that records should be imported starting from the second row/record of the source data
file. This avoids importing a record containing only field names with no real data, which would need to be
deleted.
When ready to proceed, click the Import button.
107
Chapter 5 ■ Transferring Data
Notification of Results
Once the import process is complete, the Import Summary dialog, shown in Figure 5-13, will appear with a
notification of the results including the following:
• Total records added or updated
• Total records skipped because of errors
• Total fields skipped because of errors
• Name of a table created when the New Table option was selected
108
Chapter 5 ■ Transferring Data
Figure 5-13. The Import Summary of results dialog after a successful import of the sample contact data
A text file named Import.log will be saved to the desktop containing details about the import process
and noting any errors that may have occurred.
109
Chapter 5 ■ Transferring Data
Figure 5-14. The double arrow icon indicates a pair of matching fields that will be used when updating
records on import
To denote match fields, click the icon between two fields to toggle between three choices; import
(arrow), don’t import (two dots), and match (double arrow).
When importing based on matching fields, selecting the Add remaining data as new records check
box will cause any records in the source data that can’t establish a match to be imported as new records.
After the import, the found set will remain unchanged unless this box was checked, in which case, the found
set may contain the additional new records.
When finished, a dialog, like that in Figure 5-12, will notify of the success or failure of the process.
Exporting Records
The Export Records process will save one or more selected fields from every record in the current found set
of the front window into a file of any of the supported types listed at the start of this chapter.
To begin an export:
1.
Open the database containing the records to be imported. For the examples in
this chapter, open the Contacts database we have been working with.
2.
Navigate to the desired layout containing the records to be exported. To follow
these examples, switch to the Desktop > Contacts layout.
3.
Perform a Find or Find All to establish a found set containing the records to be
exported.
4.
Select the File > Export Records menu item to open a Save File dialog, as
shown in Figure 5-15.
110
Chapter 5 ■ Transferring Data
Figure 5-15. A save file dialog, configured to save a tab-separated text sample export file
In addition to the standard save options such as name and location, the following options can be
specified:
• Type — choose from any of the available file types.
• Automatically open file — check this box to have the exported file automatically
open after saving.
• Create email with file as attachment — check this box to have the exported file
automatically attached to a new email on your default mail application.
Once the dialog options are configured, click the Save button.
111
Chapter 5 ■ Transferring Data
The controls at the top of the dialog are used to specify which fields should be exported. On the left side,
a field picker contains a popup menu from which a layout or table can be selected. The list below it displays
the fields available for export from that selection. On the right is a list of fields that will be exported. In the
middle are buttons to add or remove fields from the export list.
Selecting a Table
The pop-up menu above the field list has the current layout selected by default. This is apparently done as
a convenience to narrow the list of available fields to just those visible on the layout you are viewing. While
this can sometimes be a benefit, it can also be error-prone if you hastily click the Move All button thinking
you are selecting all fields for the table when you are not. Selecting “Current Table” from the menu will
refresh the list of fields to show all fields for the Contacts table.
Multi-table database files will include a list of related and non-related tables in this menu. While it is
possible to include a mixture of fields from the local table and fields from other related tables, this can have
unexpected results so experimentation is advisable.
112
Chapter 5 ■ Transferring Data
Figure 5-17. The field export order for the sample export
113
Chapter 5 ■ Transferring Data
Group by Option
Although not applicable to our example Contacts export, the Group by feature is allows values to be
sub-summarized during the export. If the found set of records is sorted, the Group By area of the dialog will
contain a list of the sort which can be used to summarize data during the export.
For example, imagine a found set of records with three fields containing the values shown in Table 5-2.
The Quantity Summary field is a summary that automatically totals the Quantity field for the six records
(Chapter 8, “Summary Fields”).
If these three fields were exported, the resulting file would look the same as it does in the example.
However, the data can be exported as a summary report of the total quantity for each industry following
these steps:
1.
Sort the records by the Industry field.
2.
Begin an export, and when you reach the Specify Field Order dialog, the Group
by area will have a check box for the Industry field.
3.
Add the Industry field to the export list.
4.
Add the Quantity Summary field to the export list. Two fields will be automatically
added: Quantity Summary and Quantity Summary by Industry. The second
one will be italicized, highlighting the fact that this is not an actual field in the
database, but a sub-summary of the quantity by industry, as shown in Figure 5-18.
For this example, delete the Quantity Summary field, leaving just Industry and
Quantity Summary by Industry.
114
Chapter 5 ■ Transferring Data
Figure 5-18. An example of a field export order using the group by feature
With this configuration, the result would be one row for each industry, the total quantity for all three
industries (only on the first row), and the total of each industry in the third column, as shown in Table 5-3.
Table 5-3. Hypothetical data showing how data is summarized using the Group by option
Education 95 35
Finance 15
Publishing 45
115
Chapter 5 ■ Transferring Data
Figure 5-19. The save file dialog for the Export Field Contents process
Summary
In this chapter, we discussed the basics of manually importing and exporting records from a database.
116
PART II
A database file is a type of document that contains all the structural elements you define and the data entry
content that users enter.
This chapter covers basic details about creating, configuring, and maintaining a database file, including
topics such as the following:
• Creating a new database file
• Configuring a sandbox table
• Database file options
• Maintaining healthy files
• Specifying file paths
Figure 6-1. The New File dialog, configured to create a Learn FileMaker database on the Desktop
3.
Click the Save button or type the Enter key to close the dialog and create the
new database.
4.
The Learn FileMaker.fmp12 file should appear on the Desktop and
automatically open in FileMaker.
120
Chapter 6 ■ Working with Database Files
2.
The default tab displayed in the dialog is usually Fields. Click on the Tables tab
to switch the view.
3.
Change the name of the default table from “Learn FileMaker” to “Sandbox” by
following these steps, shown in Figure 6-2:
a. Select the Learn FileMaker table in the table list.
b. Type “Sandbox” in the Table Name field.
c. Click the Change button.
b c
121
Chapter 6 ■ Working with Database Files
1 2
Figure 6-3. Steps highlighted showing the process of creating a text field in the Sandbox table
122
Chapter 6 ■ Working with Database Files
2
3
Figure 6-4. Steps highlighted showing the process of creating a calculation field in the Sandbox table
For now, just ignore the rest of the dialog controls and features. These will be covered in depth in
Chapters 12-24.
123
Chapter 6 ■ Working with Database Files
When the Options for Summary Field dialog appears, follow these steps shown in Figure 6-5 to
configure its settings:
1.
Click the Total of radio button.
2.
Select the Example Number field from the Available Fields list.
3.
Click the OK button to save the Options for Summary Field dialog.
1
2
Figure 6-5. Steps highlighted showing the process of creating a summary field in the Sandbox table
For now, just ignore any other summary options. These will be covered in depth in Chapter 8.
Now the Sandbox table should contain the eight fields shown in Figure 6-6.
124
Chapter 6 ■ Working with Database Files
Click the OK button to close the Manage Database dialog and save all changes made to the Sandbox table.
Setting Up Layouts
Although some tables will have more, most have at least two layouts. Let’s quickly create these, each with a
different content view specialized for a specific purpose:
• A Form layout is used for viewing and performing data entry tasks.
• A List layout is used for viewing and scrolling through many records, navigating to a
Form layout, and for batch processing data entry tasks.
125
Chapter 6 ■ Working with Database Files
of the layout and to distinguish it from the other layout we will construct, rename it “Sandbox Form” by
following these steps:
1.
Enter Layout mode by selecting the View > Layout menu item.
2.
Open the Layout Setup dialog by selecting the Layout > Layout Setup
menu item.
3.
In the Layout Name text area on the General tab, shown in Figure 6-7, change the
name to “Sandbox Form.”
Figure 6-7. The Layout Setup dialog with the new layout name entered
4.
Click the OK button to close the window and save the change.
Ignore the other settings in this dialog and other layout features. These will be covered in more detail in
Chapter 28.
126
Chapter 6 ■ Working with Database Files
Figure 6-8. Dragging fields from the Field Picker dialog onto the layout
3.
Click, hold, and drag the list of fields onto the layout and then release. The fields
should appear on the layout, neatly aligned and sized according to their data type.
127
Chapter 6 ■ Working with Database Files
3 4
128
Chapter 6 ■ Working with Database Files
2 3
Figure 6-10. The expanded Field Picker, configured to place fields onto the list layout
1.
In the Field Picker dialog, click the Drag Options disclosure triangle to reveal
additional controls at the bottom.
2.
Select the Horizontal option icon for Field Placement.
3.
Select the Place labels above fields icon for the Labels option.
4.
Select every field except the container field by clicking on each field while
holding Command (macOS) or Windows (Windows). We’ll skip the container
field on the List view since it will default to a large vertical footprint and attempt
to expand the layout.
5.
Next drag the selected fields onto the layout. Be sure to place them high enough
so you don’t receive a dialog asking if you want to expand the layout space.
6.
Once placed, drag them down so that the fields are roughly centered in the Body
part, as shown in Figure 6-11.
129
Chapter 6 ■ Working with Database Files
Figure 6-11. The fields placed in the Body part of the layout
7.
Select only the field labels by clicking and dragging the cursor around them. Then
move them up slightly into the Header area of the layout, as shown in Figure 6-12.
You can move selected objects on a layout with the mouse or arrow keys.
Figure 6-12. The field labels moved up into the Header area
8.
To finish up, remove the repetitive “Example” portion of the field labels. To edit a
text label, double-click the cursor to activate it, then select and delete the extraneous
word. When finished, click on the background and repeat with the other labels.
9.
Finally, scroll to the right and adjust the size and position of the last two fields
so nothing extends into the gray area beyond what will be the visible layout, as
shown in Figure 6-13.
Figure 6-13. The fields with cleaned-up labels and adjusted so none extend too far to the right into the gray area
130
Chapter 6 ■ Working with Database Files
Open Settings
The Open settings tab, shown in Figure 6-14, contains settings that control behaviors and actions that take
place when a database file is opened.
Figure 6-14. The Open settings tab of the File Options dialog
• Hide all toolbars — This setting will hide the toolbar and formatting bar
automatically each time the file is opened, allowing the user to manually show them
again as needed. A script that uses the Toggle Toolbar script step can also perform
this function with greater variablity at startup or in response to other events.
■■Tip The Switch to layout preference will be executed preceding all Script Triggers in the file’s launch
sequence. Use this setting to instantly open a splash screen or menu while avoiding screen refresh “flashes,”
which can be a distraction to users.
Icon Settings
The Icon settings tab, shown in Figure 6-15, allows an icon to be assigned that will represent the database file
in the Launch Center in FileMaker Pro or FileMaker Go. The default icon is the FileMaker document icon.
Figure 6-15. The Icon settings tab of the File Options dialog
■■Note The assigned icon does not affect the file icon on a macOS or Windows desktop, only how it appears
in FileMaker Go.
132
Chapter 6 ■ Working with Database Files
Spelling Settings
The Spelling settings tab, shown in Figure 6-16, contains settings that control automatic spell check within
a database file.
• Indicate questionable words with special underline — This setting will cause
FileMaker to display a red dotted line under any potentially misspelled words in a
field with focus unless that field or object has been configured in the Inspector to
disable the feature (Chapter 29).
• Check spelling as you type — When Beep on questionable spellings is
selected, a beep will sound anytime a user types a word that the dictionary indicates
might be misspelled.
Text Settings
The Text settings tab, shown in Figure 6-17, contains settings that control how text is entered in fields.
133
Chapter 6 ■ Working with Database Files
Text Handling
The following settings control various text handling functions:
• Use smart quotes — This setting will cause FileMaker to enter apostrophes and
double-quotation marks into fields as curly quotes.
• Use Asian language line-breaking — This setting controls how line endings are
handled when a word reaches the edge of a text field when using Asian languages.
• Use Roman language line-breaking — This setting controls how line endings are
handled when a word reaches the edge of a text field when using Roman languages.
134
Chapter 6 ■ Working with Database Files
135
Chapter 6 ■ Working with Database Files
Saving a Copy As
FileMaker allows you to save a copy of an open database file for various purposes including:
• Making backup copies
• Creating a portable, self-contained copy
• Maintaining the health of a file
• Troubleshooting damage
• Repairing damage
To use the function, follow these steps:
1.
Open the database you want to copy.
2.
Select the File > Save a Copy As menu item. This will open the Create a copy
named dialog, shown in Figure 6-19.
3.
The default entry in the Save As text area of the dialog will be the name of the
original with the word “Copy” added to the end. However, you can enter a new
name if desired.
4.
Select the folder location into which the new file should be saved.
5.
In the shaded options area at the bottom of the dialog, the Type pop-up menu,
offers a choice of the following four options for the type of copy to be saved:
• Copy of current file — This option will save a literal copy of the database.
• Compacted copy (smaller) — This option will save an optimized copy of the
database with empty space removed, resulting in a smaller file size. This can
be performed periodically to maintain the health of a file, especially if a lot of
resources or records are deleted from a file.
• Clone (no records) — This option will save a copy of the database structure
including tables, fields, page setup options, field definitions, custom functions,
layouts, scripts and other resources but without any records. This is useful for
some troubleshooting tasks as it quickly isolates file structure.
136
Chapter 6 ■ Working with Database Files
• Self-contained copy (single file) — This option will save a copy of the
database with any external container data embedded in the file’s container
fields, making it fully self-contained.
6.
Once the desired options are selected, click the Save button to complete the
process. A copy of the file will be saved in the folder you specified.
Checking Consistency
Every time a database is opened, FileMaker checks the file and, if it detects the need, automatically performs
a consistency check. This typically happens after a file has been improperly closed.
A consistency check will read every block that makes up a file and verify that the internal structure of the
block is valid and the block is properly linked to other blocks. It does not read the data within blocks or check
the file schema or higher-level structures; these functions are only performed by the full Recover command.
A manual consistency check can be performed on a file that is suspected of damage. To do so, follow
these steps:
1.
Launch the FileMaker application.
2.
Select the File > Recover menu.
3.
Navigate to the folder containing the file suspected of damage and select it.
4.
Instead of clicking the Select button, which would begin the Recover process,
click the Check Consistency button, shown highlighted in Figure 6-20.
Figure 6-20. Click the Check Consistency button in the Select Damaged File dialog after selecting a database.
137
Chapter 6 ■ Working with Database Files
FileMaker will immediately check the file and report the results in a dialog and Recover.log file saved
in the same folder that contains the file. Dismiss the results dialog by clicking the OK button.
If no problems have been reported, the file is probably safe to continue using. If damage is reported, it
may recommend performing the full Recover process. If you suspect there may still be a problem with the
file, continuing this process may be a good idea.
After the consistency check is complete, the Select Damaged File dialog remains open as a
convenience. You can either choose to continue the full recovery process on the file, which is still selected,
or opt to select a different file and quickly perform the consistency check on it as well. When finished
checking files, click the Cancel button to dismiss this dialog.
Recovering a File
When a FileMaker database becomes damaged beyond other means of repair, the Recover function can
be used to rebuild a file, regain access, and prevent the loss of data. This function is aggressive and will do
whatever is necessary to restore access to a file. It will rebuild the file block by block and attempt to correct
any corruption. However, if an object can’t be repaired, it may be deleted. Because of its aggressive nature,
the function should not be used as regular maintenance.
Before recovering a file, be sure to rule out other issues as the result of odd behavior you may be
witnessing. While not an exhaustive list, a few examples of problems caused by development errors or other
problems include:
• Incomplete or incorrect find results may be the result of either corruption (which
would be repaired by saving the file as a compacted copy) or something like
mismatched field types, such as a calculation field that is configured to result in a
number or date when it returns a text value.
• Poorly designed scripts might accidently delete records or overwrite data.
• Incorrect or broken relationship settings can result in odd behavior.
• Networking issues may cause weird behavior, which a simple quit and re-launch of
the database may remedy.
Problems that may require recovery include:
• Inability to open a file.
• Odd indexing behavior.
• Records appearing blank or with question marks in every field.
• Random crashing of the application.
To perform a recovery follow these steps:
1.
Launch the FileMaker Pro application.
2.
Select the File > Recover menu item.
3.
In the Select Damage File dialog, locate and select the damaged database, then
click the Select button.
4.
A Save dialog will appear, allowing you to name the new recovered file, choose a
save location, and optionally specify advanced options.
5.
Once finished, click the Save button.
138
Chapter 6 ■ Working with Database Files
6.
A dialog message will inform you when the process is complete and summarize the
activity performed. A Recover.log file, saved in the same directory as the new file,
will contain additional information about the activity performed and the results.
Based on the results, you can determine if the file is safe for use or if you should transfer the records into
a previously saved backup copy.
The Generate new file radio buttons provide the choice of one of three options for how the new file is
generated:
• Copy file blocks as-is — This option will copy all file blocks exactly as they exist
in the source file. The resulting file may still include damaged blocks. This is the
equivalent of using the File > Save a Copy As menu item and choosing the Copy
of current file option.
• Copy logical structure (same as Compacted Copy) — This option will copy
all the data in the source file without checking the blocks but it will rebuild the tree
structure. The resulting file may still include damaged blocks. This is the equivalent
of using the File > Save a Copy As menu item and choosing the Compacted Copy
(Smaller) option.
• Scan blocks and rebuild file (drop invalid blocks) — This option rebuilds
the file, including only undamaged and non-duplicate blocks. The resulting file can
be used but may be structurally unsound and should be used to extract data into a
reliable backup copy of the solution.
139
Chapter 6 ■ Working with Database Files
The remaining check boxes can be selected as needed to achieve the desired result.
• Scan blocks and rebuild file (drop invalid blocks) — Check this box to
rebuild the file’s database schema (tables, fields, and relationships). This option will
find and remove any fields or records found to be at invalid locations within the file
and will re-create missing fields and table definitions, all of which may take a long
time depending on the size of the file.
• Scan and rebuild scripts, layouts, etc. (structure) — Check this box to
rebuild the file’s structure (layouts, scripts, themes).
• Rebuild field index — Check this box to choose an option of whether to rebuild
indexes Now or Later. Rebuilding indexes now makes the recovery process take
longer but the work is done before users access the file. Rebuilding later forces
indexing to occur as users begin searching or performing other functions, which can
be time consuming. Uncheck the box to copy indexes without modification.
• Delete cached settings— Check this box to remove recent/last settings such as
page format, print settings, layout formatting defaults, import/export order, sorts,
finds, and send mail options.
• Bypass startup script and layout (requires admin privileges) — Check this
box to bypass any OnFirstWindowOpen or OnWindowOpen script triggers (Chapter 37)
for the file and open to a newly created blank layout.
Once finished, click the OK button to save settings and return to the Save dialog and continue with the
recovery process.
140
Chapter 6 ■ Working with Database Files
These erroneous actions are not limited to a human user. A poorly designed or inadequately tested
script can perform all the same mistakes as a user, and they can do so in much greater volume with the
speed and efficiency unmatched by a human user.
When writing scripts Chapters 34-27 ensure that the script’s actions are correct, properly limited,
context sensitive, and well tested. Spend adequate time designing and testing every script, especially those
that perform automatic record deletions or field modifications to ensure that they are designed with safety in
mind and will only carry out functions exactly as intended.
141
Chapter 6 ■ Working with Database Files
• User Efficiency — When an experienced user mistakenly deletes the wrong record(s),
it is often the result of their own efficiency within the system. While a conscientious
new user will carefully read a dialog message and proceed with more caution, an
experienced user, especially those who use key commands to more quickly perform
various tasks, can get into a sort of “road hypnosis” autopilot mode that makes them
more error prone. Combine a vague dialog with a user who thinks they know exactly
what they are doing, anticipating dialogs without reading them, and you may find
yourself with erroneous deletions.
The best way to address this problem is to override the default Delete Record and Delete All Records
commands WITH custom menus (Chapter 33). This allows the implimentation of one or more protective
measures, including:
• Restrict Access — The security settings of a database (Chapter 40) can completely
restrict access to either or both delete commands for certain users in some or all
tables. This option won’t work for every situation, but is prudent when there is a class
of users who never require the ability to delete records.
• Explicit Dialogs — With a custom script overriding the delete functions, the message
presented in the dialog can be improved to include additional information such as
the table name to make it clear exactly what is going to be deleted. For example, the
message might read, “Really delete the 100 Contact records in the found set?”
• Multiple Dialogs — Adding a second confirmation dialog can help avoid
accidental deletions, especially those involving large groups of records. This can
be inconvenient for the user but helps avoid the greater inconvenience of deleting
something mistakenly.
• Require Explicit Confirmation — When a confirmation dialog is generated using a
layout rather than the Show Custom Dialog script step, you can include a field into
which the user must type the word “Delete” or some other explicitly confirmation of
the impending action.
• Set Limits — Setting limits on how many records can be deleted at once is a good
can help avoid accidents. If a found set is greater than a chosen limit, an alternative
dialog can inform the user that their request to delete the found set is denied.
142
Chapter 6 ■ Working with Database Files
Inefficient Design
An inefficient design can greatly increase the size of a file and may discourage the addition of time saving
features a for fear of creating more clutter.
Some examples of things to watch for include:
• Internal Container Storage — If a database doesn’t need to be portable, use external
container storage instead of internal (Chapter 10). This will keep all attachments
linked and accessible from within the database but store them in a folder outside the
database, which greatly reduces the size of the file.
• Redundant Technical Structures — When planning tables, fields, relationships, and
layouts, be sure to avoid anything that would cause a redundancy. Remember when
tables are related, field information can be accessed and shared across a database’s
information hierarchy. If possible, avoid repeating anything anywhere.
• Indexing — Field indexing will impact file size you can’t avoid indexing completely
and wouldn’t want to; however, be sure you learn how to use the options wisely to
minimize excessive indexing (Chapter 8).
• Graphics on Layouts — Designing a graphically rich interface can improve the user
experience and help workflow efficiency. However, it can increase the size of the file
and the length of time it takes to load and draw layouts. Consider these strategies to
avoid this problem:
• Use FileMaker’s built-in icons for buttons where possible.
• Optimize graphics for screen use, especially if they are not on print layouts.
• Keep commonly used graphics, such as logos, in a single global container field
that stores externally if possible; then place the field on multiple layouts as
needed.
Please don’t feel limited by these suggestions. There are doubtless many other ways to be inefficient in
a database and numerous creative techniques for maximizing efficiency. Further, it would be improper to
consider any of these suggestions as appropriate in every context, and a violation of them where needed may
be perfectly valid and even recommended in some situations.
143
Chapter 6 ■ Working with Database Files
Fragmentation
Even a file with an award winning and highly efficient technical design will eventually require some
maintenance to avoid the bloat of empty “ghost” blocks. As records and resources are created and deleted
through the course of normal data entry work and development changes, empty space will accumulate
within the database file. Over time, this will artificially inflate the file size and may impact performance
and stability.
To solve this problem, use the Save a Copy as command and choose the Compacted Copy option
(described previously in this chapter). This will safely re-create the file, fitting as much data into each block
as possible and reclaiming unused space.
144
Chapter 6 ■ Working with Database Files
• Keep the operating system of host and user computers updated to the latest
compatible and stable version.
• Use the latest updater for your version of FileMaker Pro to ensure the latest bug fixes.
• Keep an adequate uninterruptable power supply and surge protector on all
computers, especially the database host, to avoid sudden shutdowns in the event of
a power loss.
• Run regular hardware maintenance using a disk utility program and don’t let
computers get outdated to the point of risking failure.
• Use fast hardware and networking equipment with adequate cabling.
Performing Maintenance
Perform regular database file maintenance, including:
• Save as compacted
• Run consistency checks
• Check for file damage
145
Chapter 6 ■ Working with Database Files
146
Chapter 6 ■ Working with Database Files
■■Caution By exporting to a non-FileMaker format, we guarantee that the data is cleanly separated from
any structural file corruption. However, container fields are not supported in these other formats and can’t
be exported. If the database has containers, those must be manually restored into the new database at the
completion of this process when performing this process. In this case, you may attempt to export to the
FileMaker format, but should double-check to confirm that no corruption accompanies the data.
5.
Repeat steps 3 and 4 for every table in the database.
6.
Identify a stable copy of the database structure (without records). Ideally use a
clone that was created from a time prior to the corruption event. If that is not
available, use the recovered copy generated after the database structure check.
7.
Import the records from the spreadsheet into this structure, being sure to use the
Arrange by Matching Names option.
8.
Repeat steps 6 and 7 for every Excel export generated above.
147
Chapter 6 ■ Working with Database Files
Formatting Paths
As indicated by the text examples shown at the bottom of the dialog, FileMaker can handle a variety of
different types of paths. The path(s) entered can be a local directory, server folder directory or a FileMaker
Server network address. The File Path List text areas can contain one or more carriage return-delimited
file paths. If more than one path is entered, FileMaker will check each one, in the order entered, until it finds
a valid path. This comes in handy when working in a network with a mixture of macOS and Windows users
of the database, as you may need to enter multiple paths to handle each user’s operating environment.
148
Chapter 6 ■ Working with Database Files
Properly formatting a path or knowing when to use multiple paths can be tricky, especially when
addressing files in a directory instead of addressing a file hosted on a FileMaker Server. There are various
prefixes that can be somewhat mixed and matched with different path format types. If a path is incorrectly
entered or the target file is moved after a path has been defined, an file missing error will occur.
To avoid errors, it is generally a good idea to use the Add Files button and subsequent Open File
dialog to select a database file because FileMaker will then formulate the best path option automatically.
This can be a good way to learn exactly how a path should be formatted. Once entered, you can always
customize the path as needed.
Path Prefixes
There are four path prefixes that can be used depending on the type of path and the operating system:
• file: — used to create a generic, cross-platform path.
• filemac: — indicates a path to a folder for use on a macOS computer.
• filewin: — indicates a path to a folder for use on a Windows computer.
• filenet: — indicates a path to a FileMaker Server hosted database.
To create a file path for use with the Insert PDF script step or the Insert Picture script step, use a
prefix of image, imagemac, or imagewin.
To create a file path for use with the Insert Audio/Video script step or the Insert QuickTime script
step, use a prefix of movie, moviemac, or moviewin.
Path Types
FileMaker paths can be defined as the following different types:
• Relative path
• Full path
• Network path (Windows)
• FileMaker server network address path
Relative Path
A relative path is a path to a target database file that is specified from the context of the database’s location.
This type of path assumes the current file and the target database have a portion of their directory location in
common and only specifies the difference between them. The formula for a relative path is:
file:[pathDifferential]fileName
The file: prefix and fileName are required values and the path differential is only included if there is a
difference between the two folders containing them.
In the following examples, we assume two files: Test Source and Test Target, with the former
defining a data source targeting the latter.
149
Chapter 6 ■ Working with Database Files
file:Test Target
In this case, there is no need to include any information about the difference between their locations
because they are located together.
Given this, the data source path in Test Source that points to the target file would be:
file:../Documents/Test Target
The first part of the path differential, the two periods and forward slash, together indicate that, to locate
the target, we must first move up the directory hierarchy one folder. The second part indicates the downward
folder structure that is required to locate the file.
However, when the source is placed into a new folder on the Desktop, we must add and additional set of
periods and forward slash to indicate the need to move up the hierarchy twice before navigating downward.
In this example, the two files are in the following locations:
Given this, the data source path in Test Source that points to the target file would now be:
Now we are telling FileMaker to look for the target file two folders up from the source folder and then
down into Documents and then into Target Subfolder.
Generally, you may want to avoid using relative paths unless the databases will always be within the
same folder or inside of a mix of subdirectories within the same root project folder that will always remain
intact and static — or if the files are hosted on the same FileMaker Server.
150
Chapter 6 ■ Working with Database Files
Full Path
A full path is a path to a target database file in a directory that is specified from the context of the disk or
volume containing it. This establishes an absolute path that doesn’t change, regardless of where the source
database is located. These can be used for macOS directories locally or on a server and for Windows local
directories.
The formula of an absolute path varies slightly depending on the operating system of the user
computer:
filemac:/volume/directoryName/fileName
filewin:/driveLetter:/directoryName/fileName
For example, if the file is in the /User/Documents folder on a macOS computer, the path might be:
Alternatively, the generic file: prefix will work for full paths that are cross-platform:
filewin:/computerName/shareName/directoryName/fileName
filewin:/Company_Server/Databases/Sales/Test_Target
fmnet:/addressOrName/fileName
fmnet:/192.100.50.10/Test Target
fmnet:/FileMaker-Server.local/Test Target
If the source database is located on the same FileMaker Server as the target, a relative path can be used:
file:/Test Target
151
Chapter 6 ■ Working with Database Files
Set Variable [ $pathToExport ; Value: "filemac:" & Get ( DesktopPath ) & "Reports/"
Import Records [ With dialog: On ; "$pathToExport" ; Add; UTF-8 ]
The path text can include variables mixed in with literal text. This allows certain values to be set
universally by storing them in a global variable and inserting the variable in their place in a path. For
example, if a network address and file name for a commonly used target file is each stored in respective
variables, the path becomes more dynamic, as shown here:
fmnet:/$$ServerAddress/$$FileName
■■Caution Variables are only fully supported in script steps that use stored paths. Stored container fields
may accept a variable path but it will not perform in a desirable manner.
152
Chapter 6 ■ Working with Database Files
fmnet:/*/Test Target
This prompted FileMaker to search the network for the file on any eligible FileMaker Server. However,
due to the impact these have on network traffic it is recommended that you not use these and, if converting
an older file, search and replace these with a proper path.
Summary
In this chapter, we discussed the basics of creating, configuring, and maintaining database files as well as the
how to refer to files by specifying paths.
153
CHAPTER 7
A table is a collection of information pertaining to some specific type of entity, made up of a collection
of records. They are the central focal point of the database structure, or schema. Tables define the field
structure of the data that will be stored within them (Chapter 8). Instances of tables can be interconnected
to form relationships (Chapter 9). A table’s fields can be displayed on layouts (Part 4) and manipulated with
scripts (Part 5).
In this chapter, we will begin defining and building tables. Topics will include:
• Modeling tables
• Introducing the manage database window (Tables)
• Naming tables
• Managing tables
Modeling Tables
Data modeling is a term used to describe the process of planning and creating an abstract, virtual
representation of the various properties, relationships and actions that describe a set of related entity classes
that will be managed within a database. This term is used because the resulting table, field, and relational
structures of a database are sometimes called a virtual model of the types of entities that are represented by
the data structure.
The first step in planning a database model is to determine the names of the tables required. A table’s
object category might be a broad category (people or products) or a narrower subcategory (employees or cars),
depending on the specific needs of the database you are building. In some cases, a table may even model some
aspect or property of an entity or action, such as a quality of an object or process of an event.
In the early planning stages, a data model can simply be a list of table names. Later, you will want to
sketch out a list of the fields that will be defined within each and indicate how the tables will interconnect to
form a relational hierarchy.
For now, our hypothetical data model can simply list the entitiy classes that will each be represented by
a table. For example:
• Company
• Contact
• Project
As we expand into other areas of the data structure in later chapters, we will expand this model.
2
7
3 4 5 6
156
Chapter 7 ■ Working with Tables
Table Properties
Tables are made up of five components, each listed as a column in the Table List on the Tables tab of the
Manage Databases dialog.
• Table Name — This column contains the name of each table in the list.
• Source — This column contains the source type of each table, either “FileMaker” or
the name of an ODBC data source.
• Fields — The Details column includes a count of the fields that are defined for
each table (Chapter 8).
• Records — The Details column includes a count of the records that are stored in
each table.
• Occurrences in Graph — This column contains a comma-separated list of every
occurrence of the table in the relationship graph (Chapter 9).
Naming Tables
Table names can be flexible depending on a developer’s preferences. Depending on the database’s design,
users may never even be aware of a table name so naming isn’t typically important from an interface
perspective. However, from the perspective of an often-overlooked technical design, naming can greatly
impact your performance as a developer when working in the programming interface.
157
Chapter 7 ■ Working with Tables
Project Resources
Project_Resources
ProjectResources
Beyond these, consider what constitutes a good table name. Ideally, the name of any object in a
database should be carefully planned to be clearly descriptive, concise but not cryptic, and integrated with
similar objects into groups but still differentiated from each another. All this while considering how the
name affects sorting with other objects in a list.
Here are a few guidelines to consider:
• A table name should clearly indicate the class of entity being modeled by the table
while being concise without being cryptic.
• In almost every case, using full words is preferred over abbreviations. If a word seems
too long, consider using a thesaurus to find a replacement.
• Remember, the choice of naming should be considered in the full context of other
tables in the file. For example, Stuff may be unclear but acceptable in a database
that manages only one kind of stuff. However, as a database expands to include
multiple tables containing data for several different kinds of stuff, it becomes
prudent to use more descriptive names like Inventory, Resources, Supplies, etc.
• Consider using several words to increase clarity where applicable. When there are
other tables that store data for similarly named entities, make sure that their names
differentiate each table’s uniqueness. This will help avoid developer confusion.
• Including prefixes to group tables will help to integrate them into subgroups
by causing them to sort together alphabetically. This is especially helpful when
selecting a table in pop-up menus throughout the developer interface. A prefix can
be one or more words but shouldn't expand the name to the point where it causes
the opposite of cryptic vagueness, cluttered overload. Sometimes a grouping prefix
may require a reversal of common language order. For example, instead of Company
Property and Personal Property, reversing these as Property Company and
Property Personal allows the common term to become a sorting prefix as well as
entity class identifier.
• Be consistent in usage. For example, consider keeping all names either singular
or plural; Contact and Company or Contacts and Companies are both fine, while
Contacts and Company is inconsistent.
158
Chapter 7 ■ Working with Tables
Using the above advice, consider a few examples of good table naming below:
Company
Company Offices
Contact People
Contact Company
Contact Log
Project
Project Budget
Project Scheulde
Invoice
Invoice Line Item
Invoice Purchase Order
■■Note Remember, your preferences and needs for naming may be validly different than the isolated
suggestions above. Never assume there is an absolute, context-less rule for naming that must be followed all
the time.
Managing Tables
Tables can be selected, added, renamed, and deleted using the buttons on the Tables tab of the Manage
Database dialog.
Selecting Tables
Many table management functions require a selection of at least one table. Selections can be made in the
following ways:
• To select a single table, click on it in the list with the cursor. To change the selected
table, click on a different table or use the Up and Down arrow keys to select the
previous or next table.
• To select multiple consecutive tables, hold down the Shift key and click on two tables
at the outside of the range desired.
• To select multiple non-consecutive tables, hold down the Command key and click on
each desired table, one at a time.
159
Chapter 7 ■ Working with Tables
Adding Tables
There are six different methods for adding tables to a database file:
• Creating a new table.
• Adding a table from an ODBC data source.
• Duplicating an existing table.
• Importing a table.
• Automatically converting a data file to a database.
• Importing records (Chapter 5, “Selecting a Target Table”).
Figure 7-2. The connection between a FileMaker and an external data source through an ODBC connection
FileMaker can act as an ODBC client application or as an ODBC and JDBC data source. As a client
application, FileMaker supports connections to external SQL data sources such as those from Oracle,
Microsoft SQL, and MySQL. Once connected, tables from the external database can be added to a FileMaker
database and, except for a few exceptions, can be used like a native FileMaker table.
160
Chapter 7 ■ Working with Tables
The process of configuring a host computer and database for ODBC access is a relatively straightforward
three-step process:
1.
Prepare the host computer for an ODBC connection with a Driver Manager and
Client Driver.
2.
Connect the FileMaker database to the ODBC client driver.
3.
Insert and use ODBC tables in the FileMaker database.
161
Chapter 7 ■ Working with Tables
■■Note The driver is a fully functional demo, limited to display only the first three rows resulting from any
query. Purchase a license key from Actual Technologies web store to remove this limit. They have two editions
available, one for use on a single user database and another for shared databases.
Configuring Driver
Next, add and configure a driver for the specific database to which a connection will be made by following
these steps:
1.
Open the ODBC Manager application, shown in Figure 7-3.
Figure 7-3. The ODBC Manager application window with a single ODBC connection configured to a sample
database
2.
Click on the System DSN tab.
3.
Click the Add button.
4.
A panel will appear attached to the dialog. Choose the appropriate driver from
the list for the specific database you are connecting to. The list will include the
following four driver options from Actual Technologies:
• Actual access
• Actual open source databases
• Actual oracle
• Actual SQL server
162
Chapter 7 ■ Working with Tables
5.
Enter settings into the multi-panel driver configuration dialog. The specific
settings required will vary slightly depending on your choice of driver. However,
generally, you must enter the server address, database name, username,
and password.
6.
When finished, click the Done button to close the configuration dialog.
7.
The final panel of the configuration dialog allows you to test the connection to
ensure that you have entered everything properly.
8.
Quit the ODBC Manager application.
163
Chapter 7 ■ Working with Tables
An empty Edit Data Source dialog will appear, like the one shown in Figure 7-5. Following the steps
below to configure the connection to the Client Driver for the external data source.
2
3
1.
Enter a name for the data source in the Name text area, which will be used to refer
to the data source within the FileMaker database. It can be the same as the Data
Source Name or a more descriptive name (as shown).
2.
Select the ODBC radio button for the Type.
3.
Click the Specify button on the right of the DSN text area.
4.
In the Select ODBC Data Source dialog that opens, select from the available
ODBC Data Sources. The list will include any you have previously defined in
the ODBC Manager application. Once you select the desired driver, click the OK
button to close the dialog.
5.
Choose the Authentication option to indicate how a username and password
should be entered at the user level when they attempt to access resources in the
external database from within FileMaker. For the smoothest user experience,
hard-code the user name and password directly in this area. For a more secure
experience, have them prompted to enter these values at runtime.
6.
Optionally, you can add filtering criteria to control which tables are displayed
when a connection is made. This can be helpful when a database has many
tables and you want to limit which are available from FileMaker.
7.
Click the OK button to close the Edit Data Source dialog and save the current
configuration.
164
Chapter 7 ■ Working with Tables
The new external data source should appear in the list on the Manage External Data Sources dialog,
shown in Figure 7-6. Click the OK button to close the dialog and save the configurations.
Figure 7-6. The dialog after setting up the connection to the external data source
4
1
Figure 7-7. The process for adding an external data source to the relationship graph
165
Chapter 7 ■ Working with Tables
1.
Click the Add a table icon button, which is located on the far left of the row of icons.
2.
In the Specify Table dialog that opens, click the Data Source pop-up and select
the ODBC data source containing the table you want to add. This should refresh
the list of available tables.
3.
Click the table you want to add.
4.
Click the OK button.
A new table occurrence box should appear in the relationship graph. If you switch to the Tables tab you
will see the table in the list with italic formatting, which indicates an ODBC “shadow table.”
167
Chapter 7 ■ Working with Tables
■■Note Tables can be copied and pasted within a file and between two files.
Importing a Table
The Import button on the Tables tab of the Manage Database dialog allows one or more tables to be
imported from a different file directly. To import, follow these steps:
1.
Click the Import button. An Open File dialog will appear.
2.
Locate and open the database file containing the desired tables. This can be a
file in a folder directory or hosted by a FileMaker Server. It can be the same file
you are editing or a different file. Once opened, FileMaker will present an Import
Tables dialog, shown in Figure 7-9, listing all the tables available for import from
the selected database.
3.
Check the check box next to the table(s) to import and click the OK button.
The selected table(s) will be copied into the current database and an Import Summary dialog will report
the results, including:
• The number of items imported
• The number of items that were automatically renamed due to conflicts
• The number of errors that occurred
An Import.log file will be saved into the folder contains the destination file or onto the Desktop. If the
destination file is remotely hosted.
168
Chapter 7 ■ Working with Tables
Deleting Tables
Depending on which of the previous examples you performed, the Learn FileMaker database may now
have a bunch of duplicate tables. Fortunately, deleting tables is a simple process:
1.
Select the table(s) to be deleted.
2.
Click the Delete button.
169
Chapter 7 ■ Working with Tables
3.
A Delete Tables warning dialog will appear to confirm you want to continue, as
shown in Figure 7-10.
4.
The dialog includes a check box that, when selected, will delete both the tables
and their corresponding occurrences in the relationship graph. This choice is
optional and can vary depending on the reason for deleting the tables. For now,
you should check the box. If you were deleting a table whose relationships will
be repurposed with a new or existing table, you would want to uncheck the box
to retain those connections. The table occurrences in the graph will become
<missing table> indicating that they require reassignment.
5.
Click the Delete button in the dialog to complete the process.
6.
Manually delete and repurpose any layouts assigned to the deleted table(s).
Once complete the selected table(s) will disappear from the list. Click the OK button to commit
this change.
■■Caution When deleting a table, all records that were contained within it will also be permanently deleted.
Summary
In this chapter, we discussed the basics of working with tables, including accessing external SQL data
sources from within FileMaker.
170
CHAPTER 8
Defining Fields
Before a table can store records of information, fields must be defined. A field is a named container for one
unit of information. Fields allocate a data entry space, define what data can be placed into that space, and
control many aspects of how that data will be managed.
■■Tip Using a spreadsheet metaphor, a field is like a column; a record is like a row; and an instance of a
field for a record is like a cell: the intersection of a column at a row.
■■Note Technically, a single field can contain more than one unit of information when configured with
repetitions. For example, a person might have multiple contact methods — phone, email, social media,
messaging, etc. — and these can be placed in multiple separate fields, a single field configured with multiple
repetitions or in a single field on multiple related records using relationships (Chapter 9) and displayed in portals
(Chapter 30).
Entry Fields
An entry field is a field capable of accepting data entered by a user or a script. FileMaker has six types of entry
fields, each dedicated to a specific data type:
• Text
• Number
• Date
• Time
• Timestamp
• Container
■■Note The ability to enter data into entry-type fields is a potentiality based on their nature. The ability to
actually enter information into these will depend on various factors such as the field’s presence and configuration
on a layout (Part 4), the configuration of a script (Part 5), the user’s security access level (Chapter 40), or some
combination of these.
Text Fields
A text field is used to store any combination of letters, symbols, or numbers as a string of any length up to
ten million characters per repetition. The values can contain any text, including other data types entered as
text. This includes any mixture of text, dates, times, and numbers. Numbers in text fields can contain leading
zeros.
The structure of the text can vary depending on the field’s settings. One field may be configured to
impose various rules on an entry, requiring it to be an unformatted, single paragraph, limited to a few words,
etc., and automatically force compliance with these rules. Another field may be configured to allow multiple
paragraphs of robustly formatted text. Depending on the field, formatting can either be applied directly to
the text through the interface by a user, applied dynamically to the text based on the field settings, or some
combination of these two. Text formatting can also be superimposed on the text when a field is displayed on
a layout.
When sorting records by a text field, the values in the field will be sorted in alphabetical order. This
means that numbers contained within the text will be sorted as text. In other words, numbers will be
evaluated one character at a time so the number 10 will sort before 2, since 1 comes before 2.
Number Fields
A number field is used to store any numeric value ranging from 10^–400 to 10^400 up to one billion
characters per field.
172
Chapter 8 ■ Defining Fields
A value in a number field can include non-numeric characters that are used to format numbers. For
example, a number field can contain 5000 or $5,000.00. While these additional characters don’t adversely
affect data entry or finding and sorting records, ideally only numeric characters should be physically
entered into the field and the currency formatting should be applied dynamically based on the field display
settings on a layout (Chapter 29, “Data Formatting”) or through a separate calculation field that converts the
numeric value to formatted text for display.
When sorting records by a number field, the values in the field will be sorted in numeric order.
Date Fields
A date field is used to store a formal date within a range from January 1, 0001, through December 31,
4000.
Dates must be typed into a date field using the short date format that matches the database’s settings
for dates and times, which are inherited from the computer upon which the file was created. Files can
be configured to allow entry and display of dates based on the user’s local system (Chapter 6, “Data
Entry Handling”) or with the Use System Formats script step. The format of a date entry will vary from
one country to another so you may need to take that into consideration if your database will be used
internationally. In the United States, the default format is typically the following:
<month>/<day>/<year>
For example, January 15, 2017, would be entered into a date field as follows:
1/15/2017
If the date entry is not properly formatted or contains extraneous text, FileMaker will present an error
dialog. Although all dates must be entered as short dates, a field on a layout can be configured to display the
value in one of a variety of formats (Chapter 29, “Data Formatting”). Some examples include:
01/15/17
2017.01.15
January 15, 2017
Sunday 15 Jan 2017
When sorting records by a date field, the values in the field will be sorted in chronological order.
Date Calculations
When entering a value into a date field, FileMaker stores the value as a number that expresses the number
of days have passed since January 1, 0001. This is invisible to all users but allows a calculation to add or
subtract a number of days to a previously entered date value. For example:
( 1/15/2017 + 10 ) = 1/25/2017
( 1/15/2017 - 10 ) = 1/5/2017
173
Chapter 8 ■ Defining Fields
Table 8-1. Showing two years on each side of the temporal divide where
FileMaker switches four-digit date conversions from the past to the future
A database managing dates that fall outside of this 100-year range or that don’t fit this division pattern
must be:
• Manually entered with four-digit years
• Entered as text
• Be entered in a field with an auto-enter formula or script trigger that converts the
date to a four-digit equivalent before FileMaker imposes its conversion rule
There is one exception to the automatic conversion process. Back before the now-forgotten Y2K bug
era, older versions of FileMaker allowed two-digit dates to exist. Therefore, when performing an upgrade
conversion to a database built with one of these older copies of FileMaker, two-digit dates will not be
converted using the same method but will instead automatically receive a century of 1900. Therefore, when
upgrading an ancient database that used two-digit years for any century other than the twentieth, care
should be taken to first convert all dates prior to upgrading to a more modern version of FileMaker or import
the dates into a text field and convert them after import prior to reverting the field to a date field.
Time Fields
A time field is used to store a formal time string, which, like dates, must be entered with a time format
matches the database’s settings, which were inherited from the computer upon which the file was created.
The format used will vary from one country to another so you may need to take that into consideration if
your database will be used internationally. In the United States, the default formal is typically:
<hours>:<minutes>:<seconds> <optional_AM_PM>
For example:
11:30:59 AM
174
Chapter 8 ■ Defining Fields
Time Calculations
When entering a value into a time field, FileMaker stores the value as a number that expresses the number of
seconds have passed since midnight. This is invisible to all users but allows a calculation to add or subtract a
number of seconds to a previously entered time value. For example:
( 11:30:59 AM + 11 ) = 11:31:10
( 11:30:59 AM - 11 ) = 11:30:48
Timestamp Fields
A timestamp field is used to store a combination of a formal date and time as a single, unified string
pinpointing a specific point in calendar time.
As with date and time values, a timestamp must be entered in a short format matching the database’s
settings for each component, which are inherited from the computer upon which the file was created.
The two components are entered with a space between them, as shown here:
<date> <time>
A timestamp value can fall anywhere within the range from January 1, 0001 12:00 AM through
December 31, 4000 11:59:59 PM.
Timestamp Calculations
When entering a value into a timestamp field, FileMaker stores the value as a number that expresses the
number of seconds have passed since midnight on January 1, 0001. This is invisible to all users but allows a
calculation to add or subtract a number of seconds to a previously entered timestamp value. For example:
Container Fields
A container field is used to store any kind of document within a database, that can be entered into a record as
easily as text, dates, or numbers. Some document file types have an Interactive content layout setting that
allow for interactivity like that provided by their native applications (Chapter 29). For example, a PDF file can
be stored in a field that is placed and configured on a layout to allow a user to view and navigate through the
pages of the document as if they were viewing it in Apple's Preview application or with Adobe Acrobat. Other
file types with interactive potential are photos, movies, and audio files.
Files can be placed into container fields by using a variety of functions including Insert, Copy & Paste
or Drag & Drop. Depending on the configuration of the database and field, the files displayed in container
fields can exist within the file structure or be linked from an external folder location (Chapter 10).
175
Chapter 8 ■ Defining Fields
Display Fields
A display field is a field that automatically displays a value that is determined by its settings. FileMaker has
two types of display fields:
• Calculation
• Summary
Calculation Fields
A calculation field is a field defined with a formula statement that is evaluated by FileMaker to produce
a result automatically (Chapter 12). These are like a cell in a spreadsheet that has a formula applied
except that it is impossible for a user to type into the cell, wipe out the formula, and enter data. Just as the
spreadsheet displays the result of the formula in the cell for each row in the spreadsheet, a calculation field
displays the result of the formula for each record in the database.
Summary Fields
A summary field is a field defined to automatically calculate another field’s values across a set of records
within the same table, taking into consideration the current user’s context of found sets and sort orders. For
example, a summary field can calculate and display the total value of a field for every record in a found set or
for subsets of records based on key sort fields. Summaries are configured with a combination of field options
(explained later in this chapter) and layout configurations (Part 4).
176
Chapter 8 ■ Defining Fields
3 6
4 11
7 8 9 10
177
Chapter 8 ■ Defining Fields
7.
Help — This button opens the FileMaker help website directly to the “Defining
Database Fields” page.
8.
Print — This button will print the field definitions for the selected fields.
9.
Cancel — This button will close the dialog without saving changes made in any
tab after displaying a warning.
10.
OK — This button will save changes and close the window.
11.
Field Buttons — This group of six buttons are used to manage fields
(see “Managing Fields,” this chapter).
Naming Fields
Field naming should follow the same rules and guidelines as tables (Chapter 7, “Naming Tables”). Like tables,
field names can have spaces, should avoid reserved words, and should be consistently either singular or
plural. They should be descriptive of the content they contain or the function they serve, without being too
lengthy or cryptic. They can be named with prefixes to become visually organized when alphabetically sorted
in lists and pop-up menus, even if this requires a reversal of language; for example, using Name First and
Name Last instead of First Name and Last Name.
Any of these name formats are perfectly fine for fields:
Company Name
Company_Name
CompanyName
The examples in this book will use follow the pattern of the first, with a space between each word of the
field name.
178
Chapter 8 ■ Defining Fields
Before you consider abandoning field name prefixes to benefit development tasks, consider that, even
if fields are named from a user’s perspective, there will still be instances of field confusion in these dialogs.
For example, many fields that exist for strictly technical purposes and are not displayed on any user layout
will be visible in these dialogs. In this case, it may be better to include prefixes to group more technical fields
away from the fields for which a user might be searching.
The benefits of naming from a technical perspective are huge and you can always educate users who
may access fields through these dialogs. You can override the dialogs with your own custom menus
(Chapter 33) and scripts (Part 5), although that limits users to only functionality predefined and controlled
by you. You could even design your own dialogs with field name translations to ease this burden, but that
can become a lot of work some will find unnecessary. In the end, you will have to find the right balance for
you, your projects, and users.
179
Chapter 8 ■ Defining Fields
As you develop more complex databases and accumulate experience with more and more fields, ideas
for standard fields may become plentiful. You’ll need to learn to identify fields that should be universal
standards from those that are applicable only to some groups of tables (group standards) or those that are
applied sparingly as needed (optional standards). A universal standard field should be established only
when they are truly useful to all or most all tables.
■■Tip Professional developers pay as much or more attention to technical design and naming as they do to
interface design.
180
Chapter 8 ■ Defining Fields
To help illustrate this point, consider a list of standard and custom fields mixed together in alphabetical
order:
Creation Date
Creation Time
Creation User
Contact Name First
Contact Name Last
Modification Date
Modification Time
Modification User
Notes
Phone Cell
Phone Home
Phone Work
Record ID
While these fields are nicely arranged in subgroups due to the use of prefixes, the intermixture of the
custom fields with standard can be visually distracting and even confusing. And from one table to the next,
the position of the standard fields will change in relation to different table-specific prefixes.
Now, consider the difference when you add a super group prefix. Since the fields in the example are
from a table containing contact records, we use Contact as the super prefix for every single custom
(non-standard) field. Since all the standard fields contain information pertaining to a record, we use Record
as the prefix for them. The resulting list of fields immediately appears more orderly.
Now we have a clear separation of standard fields from custom fields. Since standard fields have the
same name and prefix in every table, they become much easier to locate and select, or to ignore when
focusing on a custom field.
181
Chapter 8 ■ Defining Fields
Not to belabor the point, but as you add additional fields to both super groups, you may consider
additional sub-prefixes to help further group similar fields. For example, the two sets of creation and
modification fields both contain a type of status for the record, so adding an additional prefix will further
refine the list by pushing these two groups together as shown here:
Not everyone will appreciate this approach, and certainly there is the risk of getting carried away and
adding too many prefixes. However, some sort of visual organization to field names can be a huge efficiency
boost for developers when navigating around the programming interface of a complex database.
Managing Fields
From the Fields tab of the Manage Database window, fields can be selected, added, renamed, modified, and
deleted.
Selecting Fields
Many field management functions require a selection of at least one field. Selections can be made in the
following ways:
• To select a single field, click on it with the cursor. To change the selected field, click
on a different field or use the Up and Down arrow keys to select the previous or next
field.
• To select multiple consecutive fields, hold down the Shift key and click on two fields
at the outside of the range desired.
• To select multiple non-consecutive fields, hold Command (macOS) or Windows
(Windows) and click on each desired field, one at a time.
• To select every field, click on any one field and type “A” while holding Command
(macOS) or Control (Windows).
182
Chapter 8 ■ Defining Fields
Adding Fields
There are four methods for adding fields to a database file:
• Creating a new field.
• Duplicating an existing field.
• Importing records (Chapter 5, “Selecting a Target Table”).
• Importing a table (Chapter 7, “Importing a Table”).
183
Chapter 8 ■ Defining Fields
184
Chapter 8 ■ Defining Fields
■■Note Changing the field’s comment can be accomplished by following this same process.
■■Caution When no warning dialog is displayed, any data in existing records will be automatically converted
to the new type and should be fine. However, it is a good idea to at least spot check to confirm this fact.
185
Chapter 8 ■ Defining Fields
Deleting Fields
One or more fields can be deleted by following this process:
1.
Select the field(s) to be deleted.
2.
Click the Delete button.
3.
A warning dialog, like that shown in Figure 8-3, will confirm that the deletion
process should continue.
4.
Click the Delete button to continue with the deletion, or the Cancel button to
halt the process.
5.
Once completed, the selected fields(s) will disappear from the list. Click the
OK button in the Manage Database dialog to fully commit to this change and
permanently delete the field(s) and any data previously entered.
FileMaker should clean up any instances of the field on layouts. However, you may need to manually
delete any uses of the now <missing field> references found on layouts in other files, script steps, and
formulas. Also, any field labels on layouts that were previously edited from the actual name of the field will
remain and must be manually deleted.
186
Chapter 8 ■ Defining Fields
Auto-Enter Options
The Auto-Enter tab of the Options for Field dialog, shown in Figure 8-4, contains settings that control
specific data that will be automatically entered into the field when a new record is created or when certain
conditions are met.
Figure 8-4. The Auto-Enter tab of the options dialog for an entry field
187
Chapter 8 ■ Defining Fields
• Serial Number — configure the entry of a serialized number into the field based on
the value in the next value text area that will automatically increment for each new
record based on the value in the increment by text area.
• Value from last visited record — automatically enter a value into the field for a
new record from the same field on the last record the user viewed.
• Data — automatically enter the static text value in the adjacent text area.
• Calculated value — used to define a calculation formula that evaluates and
places a result into the field. The formula is entered in a Specify Calculation
dialog (Chapter 12), which is accessible by clicking the adjacent Specify button.
When checked, the Do not replace existing value of field (if any) check
box below will cause the field to not evaluate the calculation if the field already
has a value from an option above or contains data previously entered by the user.
Calculated values are auto-entered when a record is created and when key fields
used in the formula are modified.
• Looked-up value — used to copy the value from a related field into this field.
Values are inserted when a record is created, immediately after the relationship is
established. Once copied into a field, the value is retained regardless of the state
of the related record and can be edited by users and scripts (assuming access and
layout settings). However, the value can be updated when the Records > Relookup
Field Values menu item is selected.
■■Caution Although all seven options are check box controls, the first five operate as radio buttons, allowing
only one to be selected at a given time. The last two operate as radio buttons with each other but can be
combined with the first set as needed.
188
Chapter 8 ■ Defining Fields
3 5
6 7
189
Chapter 8 ■ Defining Fields
Validation Options
The Validation tab of the Options for Field dialog, shown in Figure 8-6, contains settings that define the
data entry requirements for the field, allowing the database to automatically validate what the user enters
and enforce certain rules. When a field fails a validation check, FileMaker will notify the user of the error and
give them a choice of subsequent action.
Figure 8-6. The Validation tab of the options dialog for an entry field
Validation Control
The options at the top of this dialog control when field content is validated and whether a user can override
a validation warning. The two options are:
• Always — When selected, data will always be validated as it is entered by a user or
when importing records.
• Only during data entry — When selection, data will only be validated as it is
entered by a user.
■■Caution When importing records with validation set to Always, if a field can’t be validated, FileMaker will
not import the record and report it in the Import Results Dialog as a count of the total incidence of import
errors without providing any additional detail!
190
Chapter 8 ■ Defining Fields
Checking the Allow user to override during data entry will change the validation warning dialog
as shown in Figure 8-7.
With the override option unchecked, the only options in the warning dialog are:
• Revert Field — removes the recent data entry changes and restores the previous
value to the field.
• OK — returns the user to the uncommitted record where they can edit their entry to
comply with the validation requirements before attempting to commit again.
With the override option checked, the Revert Field option remains the same but the OK option
transforms into a Yes/No button combination and the message text changes, phrased as a question rather
than a strict statement:
• No — Does the same thing as the OK button in the other version of this dialog,
returning the user to the uncommitted record where they can edit their entry.
• Yes — Clicking this button will ignore the validation warning, accept the changes as
entered, and continue with the Record Commit process.
Validation Requirements
This series of check boxes on the lower portion of the Validation tab of the Options for Field dialog
allows one or more of teh following requirements to be imposed on data entry in the field:
• Strict data type — This option restricts data entry to one of the following options
from the adjacent pop-up menu: Numeric Only, 4-Digit Year Date, or Time of Day.
■■Tip The 4-Digit Year option forces them to enter a date with a full year before FileMaker performs
its automatic date conversion based on a 100-year span. This can be helpful in avoiding entry errors and
inadvertent conversions for fields that may contain dates outside of that span.
• Not empty — This option requires a value to be present in the field before the record
can be committed. It can contain any value but must contain some value.
• Unique value — This option requires that the value entered in the field for the
current record be unique for the same field across all records in the table.
191
Chapter 8 ■ Defining Fields
• Existing value — This option requires that the value entered in the current record
already exist in the same field for at least one other record in the table.
• Member of value list — This option requires the value entered in the field to be
present within the value list selected from the adjacent pop-up menu. This feature
can stop a user from typing or pasting a value into a field to bypass the assigned
value list.
• In range — This option requires that the value entered fall within a range mandated
by the entries in the two adjacent text areas. This works well not only with numeric
values but with text, dates, and times.
• Validated by calculation — This option allows a totally customized validation by
way of a formula (Chapter 12) entered by clicking the adjacent Specify button. The
formula entered must evaluate to true (non-zero) for the field to pass the validation
test.
• Maximum number of characters — This option requires that the value entered have
a character length that is equal to or less than the number entered in the adjacent
text area. This option is not available for container fields.
• Maximum number of kilobytes — This option replaces the one above for container
fields, allowing you to specify in the adjacent text area an upper limit on the size of a
file that can be placed into the field.
192
Chapter 8 ■ Defining Fields
Storage Options
The Storage tab of the Options for Field dialog, shown in Figure 8-8, contains options that control various
aspects pertaining to how information is stored within a field.
Figure 8-8. The Storage tab of the options dialog for an entry field
Global Storage
When first created, every field is local. Being a local field means the field is essentially replicated as a unique
instance of itself for each record, like a cell in a spreadsheet. The value placed within the field is local to a
single record, which is separate and different from the same field on the next record.
By contrast, a field can be defined as a global field, which is a field that contains one value that will be
shared by every record in the database. The value placed within the field is global to every record and usable
anywhere in the file. Using the spreadsheet analogy where a column represents a defined field and a row a
record, a global field is like a column with the same value in every cell for every row.
Check the Use global storage check box to convert the field to use global storage. When converting
a previously defined field to a global FileMaker will present a warning dialog reminding you that any values
contained within the field will be lost when the change occurs.
Global fields have various purposes, including:
• Making a fixed value available to any calculation formula regardless of the context or
a lack of a relational connection.
• Creating a popup menu on a layout to allow user access to actions or options. Being
a global field means a selection can remain the same for any record in the table and
can even be added to unrelated tables.
193
Chapter 8 ■ Defining Fields
■■Tip In the past, global fields were more heavily used for a variety of functions that are better managed
with variables (Chapter 12), merge variables (Chapter 30), and script parameter passing (Chapter 34). Global
fields should not be used for any task that is more efficiently handled using these modern features.
Repeating
A repeating field is any field defined to store multiple values for a single record. Instead of creating new,
separate fields for additional values of a certain type, a single field can be defined repeat any number of times.
To make any type of entry field repeat, enter the number of desired repetitions in the text area provided
on the Storage tab of the Options for Field dialog. That number indicates the maximum number of
separate values the field can contain. To make a calculation field repeat, enter the number of repetitions
in the Specify Formula dialog for a calculation field (Chapter 12). Summary fields can be configured as
repeating in an unusual way, described later in this chapter.
Field repetitions have many uses such as storing multiple phone numbers or email addresses into a
single field. However, there are a few implications that should be considered, including:
• Whatever upper limit you choose for the field and make accessible on a layout will
establish the maximum number of values that can be typed into the field. You can
increase this number later, but then you need to make the additional repetitions
visible on any relevant layouts, which may require rearrangement since you can’t
make repeating values scrollable within a finite layout space.
• A Find process will search in all repetitions, including those not displayed on the
current, or any layout. It is not possible to limit a find to just a specific repetition.
• A Sort process will only look at the first repetition.
• Calculations that use a combination of repeating and non-repeating fields may not
work together without the usage of the Extend function (Chapter 19).
• Auto-enter calculation will only work on the first repetition.
• Repeating field values can’t be easily summarized when creating reports. You need
to condense them into a single value with a calculation using an aggregate such as
List (Chapter 19).
194
Chapter 8 ■ Defining Fields
Due to the above limitations and their status as a somewhat archaic tool, repeating fields are largely
superseded today by portals (Chapter 30) to display fields as a scrollable and expandable list of related
records. While there are still valid uses for repetition, it should be avoided in most cases.
Indexing
A field index is a list of words or values generated from a non-global field’s contents behind the scenes
by FileMaker that are used when performing searches, determining the uniqueness of a field value, and
connecting records through relationships. Although index data will increase the file size of a database, they
are required by the nature of these actions and desirable to improve performance. An index for a database
field serves a function similar to those we are familiar with at the end of physical books. The value of a
database index can be analogously grasped by anyone considering the different amount of effort required
to find a subject in a large book by scanning each page from front to back instead of finding the topic in the
book’s index and flipping to the indicated page number.
FileMaker uses two different kind of indexes, depending on the type of field and the option selected:
• A value index is created from every carriage return-delimited line in a text, number,
date, time, and timestamp field, including calculation fields that return any of these
data types. This index is used to match related records and to search any field type
except text. Here, it helps to think of “value” as a paragraph.
• A word index is created from each unique word in a text field and a calculation field
that returns a text value. It is used only for searching.
Indexing options on the Storage tab of the Options for Field dialog include:
• Indexing: None — This option prevents FileMaker from indexing the field at all. Use
this for fields that don’t require searching and won’t be used to form relationships.
• Indexing: Minimal — This option, available for text fields only, will limit FileMaker
to creating a value index for the field.
• Indexing: All — This option will create a value index for number, date, time, and
timestamp fields and both a word and value index for text fields.
• Automatically create indexes as needed — This check box allows FileMaker to
automatically create indexes as needed. For example, when a user performs a search
on a previously unindexed field set to None, checking this box would allow it to
switch automatically to All and generate and store the index.
• Default language — This pop-up menu allows specification of the language to be
used for indexing and sorting values in a text field. Initially the selected value will be
that of the operating system language of the computer upon which the file was created.
■■Tip There will always be situations where you might need to customize the indexing settings. However, in
many cases, you can leave the default indexing settings as they are and FileMaker will adjust them as needed
based on user and developer activity.
Furigana Options
The Furigana option specification of a field that will receive a phonetic translation of Japanese text typed
into the field. For more information on Japanese functions, see FileMaker Pro’s documentation website.
196
Chapter 8 ■ Defining Fields
Summarization Types
The following summarization options are available in a set of radio buttons along the left side of the dialog:
• Total of — calculates the total value for the selected field in the context-set.
• Average of — calculates the average value for the selected field in the context-set.
• Count of — counts the number of records in the context-set that have any value.
• Minimum of — extracts the lowest value in the selected field for the records in the
context-set.
• Maximum of — extracts the highest value in the selected field for the records in the
context-set.
• Standard Deviation of— calculates the standard deviation from the mean of all
the values in the selected field for the records in the context-set.
• Fraction of Total of— calculates the ratio of the value in the selected field to the
total of all the values in that field.
• List of — creates a carriage return-delimited list of every non-blank value in the
selected field.
■■Caution This section contains an overview description of the functions for defining the summary field but
may be rather abstract until one integrates it with an understanding of how these fields behave when placed on
different layout parts (Part 4).
197
Chapter 8 ■ Defining Fields
1 5
Figure 8-10. The Options for Summary Field dialog with additional options visible, marked up for a
sectional overview
The Options for Summary Field dialog contains the following controls:
1.
Summarization Type — Choose the type of summarization that will apply to the
selected field to generate a value for the field you are defining. Depending on
your choice, the conditional options will vary.
2.
Available Fields — This list displays the available fields for the table in which the
summary field being defined exists. Ineligible fields, such as text, container, and
other summary fields will be gray and non-selectable. Click to select the field that
should be summarized into the field being defined.
3.
Conditional Options — This area will display either one, two, or no options
depending on which summarization type is selected. The potential options in
this area include:
• Running total
• Restart summary for each sorted group
• Weighted average
• Running count
• By population
• Subtotaled
4.
Repeating Field Handling — This pop-up menu controls how a selected repeating
field will be handled: All together or Individually. Selecting Individually in
this pop-up menu will cause the summary field to be displayed with repetitions
matching the selected field. Choosing All together will cause the sum of all the
values in repetitions of the field for a given record to be treated as a single unit in
the summarization.
198
Chapter 8 ■ Defining Fields
5.
Conditional Secondary Field Choice — Depending on the options selected, a
second list of fields will appear in this area allowing the selection of a secondary
mathematical function that should occur within the found set of records being
summarized. The options here are:
a.
When sorted by — Some summarization options allow the selection of a field
in the same table or a related table that will restart the summarization when a
new sort value is detected. This creates summaries for multiple subgroups of
records within a single found set. For example, you might want to summarize
sales per employee or revenue per client using this feature. This option is
available with the Total of or Count of summarization with the Restart
summary for each sorted group option selected, or when the Fraction of
Total of summarization is used with the Subtotaled option selected.
b.
Weighted by — When using the Average of summarization type with the
Weighted average option selected, a field can be selected that will be used
to weight the results.
■■Tip You might consider creating the Company table with standard fields only and then duplicating that for
each additional table before adding the custom fields below to each.
• Record ID (text or number) — This field will contain a unique identification number
for the record, defined to receive an auto-enter value of a serial number, starting at
some value and incremented by 1 for each subsequent record. Modification should
be prohibited.
■■Tip Serial numbers can be text or numbers, but whichever you use you should be consistent throughout
a database. Keeping all values the same width can be visually pleasing for developers and any users who may
be exposed to them on layouts. If you choose to format these as a number, consider starting at the first number
that contains the number of digits desired; start at 1000 for four-digit numbers. To start a sequence at 1, use
text formatted serial numbers with a leading zero; start at 0001. The examples in the rest of the book will
assume six-digit, text-based serial numbers with leading zeros.
199
Chapter 8 ■ Defining Fields
• Record Status Creation Date (date) — Receive an auto-enter value of the creation
date and prohibit modification.
• Record Status Creation Time (time) — Receive an auto-enter value of the creation
time and prohibit modification.
• Record Status Creation User (text) — Receive an auto-enter value of the creation
user name and prohibit modification.
• Record Status Modification Date (date) — Receive an auto-enter value of the
modification date.
• Record Status Modification Time (time) — Receive an auto-enter value of the
modification time.
• Record Status Modification User (text) — Receive an auto-enter value of the
modification user name.
• Record Notes (text) — A freeform text field allowing users to enter notes about the
entity represented by the record or the record itself.
200
Chapter 8 ■ Defining Fields
Summary
In this chapter, we discussed the basics of working with fields.
201
CHAPTER 9
FileMaker Pro databases can be relational. A relational database allows tables to be interconnected to form
relationships between records that act as a conduit for data access.
This chapter covers the following topics pertaining to relationships:
• Introducing relationships
• Managing data sources
• Introducing the manage database dialog (Relationships)
• Working with table Occurrences
• Building relationships
• Adding notes to the graph
• Organizing the learn FileMaker object model
Introducing Relationships
Relationships are powerful mechanisms of integration and add a new dimension to data management.
Without relationships, a database is like a bunch of separate documents containing one or more separate
lists. By virtue of being contained within a single database file, these lists are certainly easier to search, sort,
print, edit, and share. The layout and scripting functions allow information to be merged into various visual
formats and automatically manipulated in many useful ways. However, without relationships, the lists are
separated from each other and can’t easily interact or share information. Relationships allow data to be
dynamically connected.
Defining Relationships
A relationship is a single, bidirectional connection that integrates two tables. Relationships establish the
criteria for matching records between two tables with one or more field pairs called match fields.
A match field is any field that is used to form one side of a relationship. Two match fields, conjoined
with an operator, form a single criterion for establishing a relationship between records. In this example, a
Company record will be related to a Contact record when the former’s Record ID field matches the latter’s
Contact Company ID field:
Company::Record ID = Contact::Contact Company ID
To be established, a relationship must contain at least one pair of match fields. However, they can be
made up of various such pairs. When more than one criterion is defined, records will only match when they
all criteria return a true value.
While match fields can contain any type of value, most relationships are established with one set
containing serial numbers. These are formally referred to as local keys and foreign keys. When a match field
containing a serial number is native to a table, such as the Record ID representing a company record in a
Company table, it is referred to as a local key or a primary key. This means that the value in the field represents
the local record. Conversely, when a match field contains a serial number that represents a record from the
table on the other side of the relationship, it is called a foreign key. This means that the value in the field
represents a record in a different table. For example, a Company ID entered into a field in a Contact table is a
value from the other side of the relationship and is, therefore, foreign to the Contact record.
There are some strict indexing requirements for match fields containing foreign keys. While a field
containing a primary key need not be indexed and can even be a global field, those containing foreign keys
must be indexed and, therefore, cannot be global fields.
Relationships are viewed and managed in a graphical worksheet area called the relationship graph,
which is where table occurrences are placed, connected, and configured. A table occurrence is one instance
of a table represented on the graph by a visual object. Occurrences are pulled in from a data source, which is
a file containing the table. The data source can be the default instance of the database you are working within
or accessed from an external FileMaker file or ODBC compliant database.
By default, every FileMaker table is represented in the relationship graph by one occurrence
automatically when created. However, they can be added into the graph as many times as necessary to each
provide a unique relational context. This will be necessary when creating multiple relationships between the
same set of tables to avoid forming a circular structure, which is strictly forbidden.
Later, when developing user interfaces, layouts are assigned a table occurrence to establish the records
it will display and its context in relation to other connected occurrences. The context of an occurrence is
important to remember when designing layouts and writing scripts as it will control which fields in other
tables are accessible from a given layout. Every layout must be assigned a table occurrence; however, it
isn’t mandatory that every table occurrence is assigned a layout unless the context it establishes requires
an interface for user or script access. In cases where a table doesn’t require any occurrences, the default
instance can be deleted.
Generally, relationships connect two different tables to form a hierarchical connection. However, it
is possible and sometimes beneficial to connect a table to another instance of itself to form connections
between records within the same table.
Table occurrences can be joined together into a chain of successive relationships, as illustrated in
Figure 9-1. This is sometimes referred to as multiple hops, referring to the number of occurrence steps
removed from the first.
Figure 9-1. A diagram showing an example of a relationship chain with four “hops”
Relationships within a file can be grouped into one multi-pronged chain or into multiple separate
chains depending on the specific needs of the database and your preferences as a developer.
204
Chapter 9 ■ Connecting Tables with Relationships
• Fields can be defined to copy content from another field in a related record as easily
as they can from fields within the same table. This includes:
• Using the Lookup command.
• Pulling information into an auto-enter Calculation value.
• Using the Validated by calculation option.
• Calculation fields can access and manipulate related fields in their formulas.
• Layouts can display individual fields from related records for viewing or editing.
Using portals, they can display scrollable lists of related records. They can also use
values from related fields within calculation formulas for conditional formatting,
placeholder text, script parameters, tooltips, and hide functions (Part 4).
• Script steps can reach through relationships connected to the context of the current
layout’s table occurrence to pull information into formulas, change related values,
sort, search, and more (Part 5).
• Users can include fields from related records in search requests, sort orders or
exports depending on their level of security access (Chapter 40).
One-to-One Relationship
A one-to-one relationship is a type of connection where any one record in either table can only be connected
to a single record in the other table. Essentially, this means that the foreign key is limited to a single use of
any one primary key in the related table. In the example illustrated in Figure 9-2, the Contact table’s primary
key is contained in the Record ID field. The id for each contact record can only be assigned to a single
Cubicle record’s Contact ID field. Therefore, each Contact can be assigned one Cubicle and each Cubicle
on Contact.
Contact Cubicle
Record ID Contact Name Contact ID
00001 John Smith 00025
00002 Alex Martin 00002
Figure 9-2. Illustrating a one-to-one relationship between a Contact and Cubicle table
205
Chapter 9 ■ Connecting Tables with Relationships
The one-to-one arrangement is perhaps the least common of the connection types since it can result in
the equivalent of two sets of information in separate tables for the same entity. While one shouldn’t use such
a technique arbitrarily, there are situations where a one-to-one configuration makes sense.
For example, consider the case illustrated in Figure 9-2 with a Contact table connected to a Cubicle
table for office space assignments. In this case, even though one person can only be assigned to a single
cubicle and each cubicle is designed for a single individual, there are still reasons to keep the two sets
of fields in separate tables. First, they are two different types of entities, each with different properties.
Further, over time, people tend to change offices due to job changes or during a reorganization. If the fields
describing a cubicle were merged into the Contact table, it would not only confuse the entity class being
described by making a cubicle a property of a person, but also create extra work when a person moves to
a new location. By keeping them in separate tables, users avoid the tedious job of deleting and reentering
cubicle information into a different Contact record and instead simply delete the identification number
from one Cubicle record and reenter it on another, thereby linking the person to a new cubicle.
In this kind of situation, there is no clear requirement of which side of the relationship the primary
key should be placed. A field from either side can be selected as the entry value for the other side. As a
developer, you need to choose to build the database so either a cubicle is assigned to a person or a person is
assigned to a cubicle, depending on your preference. Whenever the physical union between a contact and
a cubicle changes in reality, a user would enter or select the new id assignment from whichever side of the
relationship your interface design allows.
The one-to-one relationship is usually achieved by means of layout design restrictions. For example,
requiring the foreign key field to be a unique value will make it impossible for a user to assign a user to
multiple cubicles or a cubicle to multiple users.
Another less common reason for a one-to-one relationship occurs when a record is connected to itself.
This may be done for error detection purposes or when generating a value list from a field value. Linking the
unique serial number field between two occurrences of the same table can only result in the establishment
of a one-to-one relationship.
One-to-Many Relationship
A one-to-many relationship is a type of connection where one record in the primary key table can be
connected to many records located in the related table. In the example illustrated in Figure 9-3, the Company
table’s primary key Record ID field for a given record can be assigned to one or more Contact records in the
foreign key Company ID field, while each Contact record is limited to a single company assignment. So, one
Company record can be linked to many Contact records.
Company Contact
Record ID Contact Name Contact ID Contact Name
00001 Write Track Media 12333 Alex Martin
12333 ABC Company 01835 Joanne Miller
85566 Awesome Inc. 12333 Jane Doe
Figure 9-3. Illustrating a one-to-many relationship between a Company and Contact table
This setup is the most common of the three because there are so many entities that can be related to
multiple entities in this way. A single company can have many employees, many products, many clients, and
many projects. One person generally has many methods of contact in the form of phone numbers, email
addresses, and web pages. A parent can have many children.
206
Chapter 9 ■ Connecting Tables with Relationships
This last example is why this arrangement is often referred to as a parent-child type relationship since,
biologically, a child only has a single father and a single mother but either parent can have many children.
So, the table containing the primary key contains the parent record and the table containing the foreign key
contains the child record(s). Technically speaking, this term can be applied to a one-to-one relationship as
well, where the side of the relationship containing the primary key is referred to as the parent and the side
containing the foreign key is referred to as the child.
With this arrangement, records can be assigned from either side of the relationship. From the parent
record, a portal can be configured to allow the creation of multiple records; each assigned the parent’s
primary id as their foreign key. From an existing child record, a field can be configured to allow a parent’s
primary key to be entered as the foreign key. Both will assign a child record to the parent and form the
relational connection.
A one-to-many relationship is controlled completely by layout design.
Many-to-Many Relationship
A many-to-many relationship is a type of connection where records in both tables can be connected to any
number of matching records in the other. There are two methods of achieving this type of relationship:
• Using a join table
• Using a multi-key field
■■Note In addition to these, it is possible to create the equivalent of a many-to-many by establishing two
separate relationships, a one-to-many and a reverse many-to-one. However, strictly speaking, this is not a
relationship type since it is spread across two separate relationships.
Figure 9-4. Illustrating a many-to-many relationship with the use of a join table
A many-to-many relationship has many practical uses. For example, when connecting people to a
company, consider a situation where you would want to not only connect a person to their current employer
but also keep track of past employers. This is possible with a join table as illustrated in Figure 9-5.
207
Chapter 9 ■ Connecting Tables with Relationships
In this example, a Company table and a Contact table are connected through an Assignment Company to
Contact join table. The ABC Company has two contacts connected to it, Jane Doe and Alex Martin. Jane Doe
has two companies connected to her record: ABC Company and Awesome Inc.
In addition to allowing many-to-many connections, one of the benefits of a join table is that fields can
be added in the join table that contain information specific to the union of the two records. So, instead of a
value pertaining to a company or to a contact person, fields in the join table allow a value to be stored with
the connection between a company and a contact. For example, a field that indicates which employment
is current could exist in the join table and be visible from the Contact side, so Jane Doe would show two
company connections, one “Active” and the other “Inactive.” Also, the contact’s current (or last) title at a
company would need to be stored in a field in the join table since that would change from one job to the next.
Once the table occurrences are connected, a portal displaying records from the join table would be
placed in both the Company and Contact tables allowing a record on either side to be assigned to any number
of records on the other.
Table 1 Table 2
New York
California 1
1 Ohio
Pennsylvania
New York
2 2
Massachusetts Pennsylvania
California
3 Ohio 3
New York
California Ohio
4 4
Ohio Massachusetts
Figure 9-6. An illustration of a multi-key field relationship showing matched relationships for the first record
in Table 1
In this example, we see the power of a multi-key field relationship. The primary key field in the
first record in Table 1 matches three records in Table 2 even though none of the primary key fields in
those records contain all the same values. When separated by a carriage return, each value is used to
208
Chapter 9 ■ Connecting Tables with Relationships
form a match, so the presence of any one value from one match field found in the other will form a valid
relationship. It is important to note that, in this example, Table 1 establishes the context perspective for
the lines indicating a match. From a Table 2 perspective, for example, the fourth record in Table 2 would
connect to both records 1 and 2 in Table 1.
The primary drawback to this technique is that, without a join table, there is no convenient location to
add fields that store information about a specific union of two records. However, if a relationship doesn’t
need such fields, this technique can be enormously useful for logistical reasons.
One example is the ease of having a duplicate of a record retains all its relationships. Normally, when
duplicating a record in a table, none of the join records will be duplicated so the new duplicate record will no
longer be connected to the records in the other table unless a custom script is created and used to override
the Duplicate menu item to explicitly perform that task. However, with a multi-key relationship, when the
foreign keys of all the related records are contained in a single field located on the record you are duplicating,
there is no additional development work required to maintain the connection to related records.
This technique is useful when creating a temporary storage and display mechanism of related
information in a selection dialog where a cancel option needs to quickly wipe out the temporary
relationship. With a single field in a temporary record containing multiple keys that form a relationship for
an adjacent portal, it is easy to remove the relationship by deleting the keys from the field.
Organizing Relationships
There are two primary methods for organizing relationships in the graph:
• Hub-and-spoke monolith
• Table occurrence groups
■■Tip Although your choice between these will depend on your preferences and the complexity of the database
you are building, the table occurrence group method is often chosen on principle for the sake of establishing an
easily scalable relationship graph and to maintain good performance.
Figure 9-7. An illustration of the pattern of a generic hub-and-spoke monolithic relationship web
209
Chapter 9 ■ Connecting Tables with Relationships
Due to the bidirectional nature of relationships, a field calculation or layout can use any occurrence
in the graph for its context. For beginners or simple databases, this tends to be the default approach and is
perfectly valid, although it is not recommended.
As more and more tables are added and interconnected, it can quickly become confusing for even the
most skilled developer to keep straight which context is which, especially if secondary duplicate occurrences
are poorly named. Each time an occurrence is duplicated, the default name is the same as the original with a
numeric suffix added to ensure it is unique. But distinguishing between Contacts-1 thru Contacts-8 can be
confusing six months later. However, even with the best naming scheme applied, it can still get confusing. In
extreme situations, a giant mass of interlocking table occurrences can even cause bad performance.
Figure 9-8. An illustration of the pattern of a generic table occurrence group organization
■■Note The phrase “table occurrence group” is somewhat awkwardly acronymized as TOG and referred to
collectively as TOGs.
In this illustration, the primary tables are shaded gray and running in a column down the left side and
secondary tables are clear and hanging off to the right in one or more hops. When using this method, all
calculation fields and layouts should be strictly limited to using only a primary instance of a table to establish
their context. From there, they can reach out and access related material from connected occurrences within
the group.
210
Chapter 9 ■ Connecting Tables with Relationships
Primary occurrences can be named the same as the actual table, Company, Contact, Project, etc.
Secondary occurrences, which will be duplicates of these primary ones, should be named in a way that
indicates their relational path back to the primary. This will cause them to sort together in pop-up menus
and lists. For example, a secondary instance of the Contact table attached to a primary instance of a Company
table could be called Company | Contacts indicating it is a secondary occurrence of the Contact table
connected to the primary Company table occurrence.
Using this method will necessitate some redundancy in the relationship graph that might at first
seem cumbersome and counterintuitive in making the graph more cluttered than it needs to be. However,
as a database grows and becomes more complex, this method will avoid the performance issues that
plague monolithic relationship design and, when combined with consistent naming rules for secondary
occurrences, it can eliminate developer confusion when trying to select the appropriate table from a pop-up
list in the development interface.
■■Tip Another method to provide access to central resources without extraneous duplication of occurrences
or even the need for any connection is using the new Card option of the New Window script step to display
records and selection controls from a context other than that of the current window (Chapter 35, “Createing a
New Window”).
211
Chapter 9 ■ Connecting Tables with Relationships
Contact
Company
Project
Figure 9-9. A simple hub-and-spoke configuration of the three example tables in the Learn FileMaker
database
By contrast, the table occurrence group method would be organized based on the illustration in
Figure 9-10. Each of the three primary occurrences on the left will be used as the context for calculations
and a layout while calculations, portals, and scripts would draw values from a related secondary occurrence
on the right. Even though this appears unnecessarily complex now, by adopting this method, it prepares for
more complexity over time and serves as a good object lesson.
Figure 9-10. A more complex table occurrence group configuration of the three example tables in the Learn
FileMaker database with duplicate, secondary occurrences attached prepares your database for growth
212
Chapter 9 ■ Connecting Tables with Relationships
Once a database is open, this dialog can be accessed by any of the following methods:
• Select the File > Manage > External Data Sources menu item while in browse or
layout mode.
• Run a script or click a button that uses the Open Manage Data Sources script step.
• Select one of three options at the bottom of the Data Source pop-up menu on the
Specify Table dialog, shown in Figure 9-12, which is used to add a table to the
relationship graph.
213
Chapter 9 ■ Connecting Tables with Relationships
1
2
214
Chapter 9 ■ Connecting Tables with Relationships
3.
File Path List — This text area is used to enter the path to the file containing
the source table.
4.
Add File — This button is used to select a file path through an Open File dialog,
which can be useful to avoid errors one may encounter when manually entering
a path.
■■Tip Beginning with FileMaker Pro 16, the file path entered can be a global variable allowing for
dynamically changing data sources.
4 5 6
215
Chapter 9 ■ Connecting Tables with Relationships
2.
Button Controls — These 19 icon buttons perform various tasks within the
graph area (see “Managing Relationships,” this chapter).
3.
Help — This button opens the FileMaker help guide to the “Creating and
Changing Relationships” page.
4.
Print — This button will print the relationship graph.
5.
Cancel — This button will close the window, without saving changes after
displaying a warning dialog.
6.
OK — This button will save changes and close the window.
Once the Object Selector Cursor tool is chosen, occurrences can be selected using any of the
following methods:
• To select a single occurrence, click on it.
• To select multiple non-grouped occurrences, hold the Shift key and click on
each desired occurrence. A second click on a previously selected occurrence will
deselect it.
216
Chapter 9 ■ Connecting Tables with Relationships
1 2
For each of these manipulations, the Object Selector Cursor tool must be selected:
1.
The heading of a table occurrence is a thick gray bar at the top of the box in which
the name of the table appears. Regardless of whether the occurrence is collapsed
or expanded, clicking and holding on this region allows you to drag the box
around within the relationship graph to reposition it.
217
Chapter 9 ■ Connecting Tables with Relationships
2.
On the right of the heading is a small expansion toggle icon. A single-click on
this icon will toggle the state of the occurrence between one of three states, two
if it isn’t yet connected to any other occurrence. Without a connection, one click
collapses the box completely and another click expands it fully. When connected
to other tables, there is an intermediate state where the box collapses to show
only the match fields used to form relationship(s) to other occurrences.
3.
The thin gray bar on the sides and bottom of the box is used to resize the box in
one direction. Click and drag on either side to expand or contract the width of
the box or on the bottom to adjust the height.
4.
Click and drag from the bottom corners to resize the box in two directions at
once, adjusting the width and height to the amount based on the direction and
duration of the drag motion.
5.
Depending on the current scroll state of the field list within the box, a small
arrow icon will appear at the top, bottom, or both. This is used to scroll up or
down the list to locate a desired field. Individual clicks will move up or down
one field at a time while a click and hold will continuously scroll the list until
released.
To prepare our four Learn FileMaker occurrences, collapse them all and move them one above the
other so they are roughly lined up in a vertical stack, as shown in Figure 9-18.
Figure 9-18. The four table occurrences collapsed and arranged in a stack
218
Chapter 9 ■ Connecting Tables with Relationships
The Vertical Alignment tool, shown in Figure 9-20, contains a pop-up menu with the following
functions:
• Align Top Edges
• Align Centers
• Align Bottom Edges
The Distribute tool, shown in Figure 9-21, contains a pop-up menu with the following functions:
• Distribute Horizontally
• Distribute Vertically
The Resize tool, shown in Figure 9-22, contains a pop-up menu with the following functions:
• Resize to Smallest Width
• Resize to Smallest Height
• Resize to Smallest Width & Height
• Resize to Largest Width
• Resize to Largest Height
• Resize to Smallest Width & Height
219
Chapter 9 ■ Connecting Tables with Relationships
Viewing Options
Under the “Tools” heading, to the right of the Object Selection Cursor and Text Note tools are four tools,
shown in Figure 9-23 that allow manipulation of the graph view.
3 4
2
1
Figure 9-23. Viewing tools used to adjust the view of the relationship graph
220
Chapter 9 ■ Connecting Tables with Relationships
• Colors can indicate the type of operator used to connect a secondary occurrence to a
primary one. For example, any occurrences that use an equal match operator could
be a different color from those using other operators.
• Colors can be used to indicate the development status of groups within the graph.
To apply a color, select the occurrence(s), click the color tool, and choose the desired color from the
palette, shown in Figure 9-24.
Figure 9-24. The color palette tool used to apply a color to an occurrence
221
Chapter 9 ■ Connecting Tables with Relationships
2.
Choose the data source containing the table you want to add, and then click to
highlight the table.
222
Chapter 9 ■ Connecting Tables with Relationships
3.
The name field will automatically be filled with a suggested name. This will be
the name of the table with a numeric suffix as needed to ensure a unique table
name. Optionally, type a new name into this field to clarify the specific context
and usage of the new instance of the table in the graph.
4.
Click the OK button to complete the process. The new table occurrence will
appear in the relationship graph for the selected table with the specified name.
5.
Resize and position the new occurrences as needed.
Deleting Occurrences
Deleting an occurrence will not delete the actual table definition, but it will cause several actions throughout
a database, including:
• The occurrence itself will be deleted.
• Any layouts that used the occurrence as its relational context will have an <unknown>
table assignment, and will need to be reassigned an existing occurrence or deleted.
• Any field on a layout that is based on the context of the occurrence will become a
<missing field>.
• Any portals displaying records from the occurrence will be broken.
• Any script steps that relied on the context of the occurrence will be broken.
To delete one or more selected occurrences, type Delete on the keyboard or click the Delete Table tool
shown in Figure 9-29.
223
Chapter 9 ■ Connecting Tables with Relationships
Before deleting the selected occurrence(s), FileMaker will present a warning dialog confirming
the request. If you mistakenly confirm the deletion, click the Cancel button at the bottom of the Manage
Database dialog to discard all changes, including the deletion.
Click the Page Break tool, shown in Figure 9-31, to toggle the visibility of page breaks in the graph area.
Once the page setup is properly configured for the desired paper and printer, click the Print button at
the bottom of the dialog to open a standard Print dialog.
Building Relationships
Once table occurrences are added and neatly organized within the graph, it is time to begin connecting them
to form relationships.
Adding Relationships
There are two methods available that connect occurrences and form a relationship: pulling a connection
between two occurrences or using the Add Relationship button.
224
Chapter 9 ■ Connecting Tables with Relationships
3.
Scroll each list of fields so that the match fields for the relationship are visible.
4.
Click and hold on a match field from one occurrence. As you begin to drag the
cursor toward the other occurrence, a line will appear connected to the first
match field, shown in Figure 9-32.
Figure 9-32. The process of dragging one match field toward the other with a relationship connection in tow
5.
Once the cursor is on top of the desired match field for the other occurrence,
release it, and the line connecting the two will be fully established.
Clicking this button will immediately open an empty Edit Relationship dialog with both tables set to
<unknown>. From there, you can select the two table occurrences from the pop-up menus and selected the
match fields.
■■Tip Consider using a combination of these two techniques to improve your efficiency. To avoid having to
scroll the occurrence boxes or enlarge them to locate the desired match fields, drag to connect any two fields
that are currently visible to quickly establish the connection. Then, open the Edit Relationship dialog to
select other fields from the larger and more easily scrollable lists. Since you will probably open the edit dialog
anyway to configure other settings, this method offers the fastest and still rather intuitive method for creating a
new relationship.
225
Chapter 9 ■ Connecting Tables with Relationships
Manipulating Relationships
Once a relationship is established, it is represented as a line connecting the two occurrences with a box in
the middle, as shown in Figure 9-34.
Figure 9-34. The relationship appears as a line with a small selector box in the middle
The box will display the operator used to form a match between the two fields, with the default being an
equal sign as shown.
At each end of the line is an indication of the type of relationship established, shown enlarged in
Figure 9-35. A straight line, like that on the left, indicates a “one” connection and the “crow’s feet” on the
right side indicates a “many.” Therefore, we have a one-to-many relationship between the Company and
Contact table occurrences. FileMaker determines this by looking only at the auto-enter settings for the
fields. Since the Record ID field in Company is configured to auto-enter a unique serial id for each record,
FileMaker assumes that this is a “one.” On the other side, it doesn’t see this setting so it assumes that it is a
“many.” Although these symbols are accurate in the case of our example, this is the extent of the logic used
to determine the type of relationship. FileMaker does not consider your layout rules, field content. or script
behaviors, which may enforce a different type of relationship.
One Many
Figure 9-35. End-of-line symbols indicate the type of connection for that side of the relationship
226
Chapter 9 ■ Connecting Tables with Relationships
When moving occurrence boxes, the relationship line will stay connected on both sides, regardless of
one box’s position relative to the other box. The single, straight line will split into three segments and change
angles so each remains straight and maintains the connection, as shown in Figure 9-36. At a certain point,
the line will snap from one side of the occurrence box to the other to maintain a connection.
Figure 9-36. As a box moves, the line splits into three straight segments that angle in relation to each other
To select a relationship for editing, click on the small box in the middle of the relationship line. When
selected, the line will darken and the box will turn blue. In the toolbar, the Edit Selection and Delete
Selection tools will become enabled.
To open the Edit Relationship dialog, either double-click on the box or click the Edit Selection
tool, shown in Figure 9-25. To delete the relationship between the occurrences, either type Delete or click
the Delete Selection tool, shown previously in Figure 9-29. Deleting a relationship will not affect the two
occurrences.
■■Caution Typing Delete or clicking the Delete Selection button will delete any a selection of table
occurrence(s), relationship or note(s). Although a warning dialog is presented prior to deleting a table
occurrence, it is still a good idea to be aware of what is selected before using these.
227
Chapter 9 ■ Connecting Tables with Relationships
3 4
228
Chapter 9 ■ Connecting Tables with Relationships
Comparative Operators
A comparative operator is used to compare two match fields, one on each side of a relationship, to determine
the type of equation used to detect a match. The available operators, shown in Table 9-1, are standard
operators familiar to any student of math.
Table 9-1. A description of the comparative operators available for forming relationships
Operator Description
= The values in both match fields must be equal to each another.
≠ The values in both match fields must be not equal.
< The values in the left match field must be less than the value in the right match field.
≤ The values in the left match field must be less than or equal to the value in the right match field.
> The values in the left match field must be greater than the value in the right match field.
≥ The values in the left match field must be greater than or equal to the value in the right match field.
X All records on the left side of the relationship will be matched to all records on the right side,
regardless of the actual values contained in the selected match fields. This is often referred to as
a Cartesian Product, Cartesian Join or Cross Join, which means a join between two tables that is
unrestricted by any criteria since every record will be a match no matter the criteria. Some prefer
to think of the “x” as a wheel of an old stage coach or cart where the spokes branch out in many
directions, relating everything to the hub in the center.
Relationship Options
The three options available at the bottom of the Edit Relationship dialog, shown in Figure 9-38, control
basic functionality for each side of the relationship.
Figure 9-38. The options at the bottom of the Edit Relationship dialog
229
Chapter 9 ■ Connecting Tables with Relationships
2.
Using the mouse, click on the background of the graph, then hold and drag. A
note will appear, steadily growing based on the direction and distance you drag
the mouse. When it is large enough, let go of the mouse button.
■■Tip A note can be quickly created by clicking and dragging on the background while holding Option
(macOS) or Alt (Windows).
Once created the note will appear on the graph and an Edit Note dialog will automatically open. The
dialog, shown in Figure 9-41, allows entry and editing of the note text as well as specification of the font, size,
text color, and background color of the note.
230
Chapter 9 ■ Connecting Tables with Relationships
When finished editing, click the OK button to save changes. Clicking the Cancel button will cause one of
two results depending on the status of the note:
• If the note has not yet been saved, clicking Cancel will close the dialog and delete the
new note.
• If the note has previously been saved, clicking Cancel will close the dialog without
saving any changes to the text or settings, leaving the note unchanged by any actions
taken in the dialog.
Once saved, a note can be moved, resized, or minimized using the cursor as you would a table
occurrence or window. Double-clicking on the note or selecting it and clicking the Edit Selection tool
will reopen the Edit Note dialog. To delete a note, select it and type the Delete key or click the Delete
Selection icon in the toolbar.
231
Chapter 9 ■ Connecting Tables with Relationships
These basic connections will allow each table to connect to another table as follows:
• Company — Each record for a company will be able to display a portal listing every
related “child” contact record: the people who work at the company.
• Contact — A record for a contact will be able to connect to its “parent” company and
display the name of the company on the layout.
• Project — A record for a project will be able to connect to its “parent” company
record as well.
Summary
In this chapter, we discussed the basics of table occurrences and connecting them to form relationships.
232
CHAPTER 10
Managing Containers
A container field is used to store any kind of document. Traditionally, and in some circles to this day, the
content of a container is referred to as a binary large object or basic large object, both commonly expressed
as the acronym “BLOB,” which is a collection of binary data representing image, audio, or other multimedia
files and stored as a single entry in a database.
The options for and behaviors of a container field depend on several factors. Various settings influence
how users or scripts insert a file into a container, how that material is stored, and how it is displayed in a
field on a layout. These factors often intersect in a somewhat confusing mixture, and your choices may be
influenced by the competing needs of functionality, user preference, and installation type – all juggled while
trying to maintain optimum performance by maintaining a lean file size.
This chapter provides an overview of the options for defining and managing containers, covering the
following topics:
• Inserting files into containers
• Understanding container storage options
• Using managed external storage
• Extracting files from containers
For more information about the options for containers on a layout, see Part 4.
Insert Menu
The Insert menu contains four options for inserting a file into a container field, shown in Figure 10-1. Each
of these is also available in the field’s contextual menu.
Figure 10-1. The Insert menu options for placing content into a container field
Choosing any of these options will open a Choose File dialog, optimized for the type of file
corresponding to the menu item. The four options are:
• Insert Picture — This option allows the selection and insertion of an image file
into the field, which will be displayed as a picture rather than a file.
• Insert Audio/Video — This option allows the selection and insertion of an audio or
video file and is only visible when the field’s layout settings are configured to allow
for Interactactive content. This allows the content to be played directly from
within the field without having to open it in another application. Audio and video
files can be placed into a field using the Insert File option or other methods but
will not be interactive.
• Insert PDF — This option allows the selection and insertion of a PDF file
and is visible only when the field’s layout settings are configured to allow for
Interactactive content. This allows pages of the PDF document to be viewed
directly from within the field without having to open it in another application. PDF
files can be inserted using the Insert File or Insert Picture menus as well as
other methods but will not be interactive.
• Insert File — This option will inset any type of file into a field. The file will appear
as it does in a directory folder, represented by an icon with no option to access or
view its content.
234
Chapter 10 ■ Managing Containers
For example, if you drop an image it will be inserted and displayed as if you selected the Insert
Picture menu item. If you drop a PDF or audio file into a field that has not been configured for
Interactactive content, the file will be placed into the field and displayed as a preview of the first page of
the PDF or as a file icon. However, if the field is configured for interactivity, the file will be inserted as if you
chose the menu corresponding to the file type.
Using this method there is no way to manually specify external storage except by using FileMaker-managed
external storage, discussed later in this chapter.
size:731,960
image:../../../../../../../../../Desktop/Flower Picture.jpg
imagemac:/Macintosh HD/Users/john_smith/Desktop/ Flower Picture.jpg
235
Chapter 10 ■ Managing Containers
The string above contains a typical reference to an image file but may vary slightly depending on
computer platform and whether the database is hosted locally or accessed from a remote server. It contains
three pieces of information:
• If the file is an image, the dimensions of the original file.
• A path to the file relative to the database.
• An absolute path to the database.
There are two ways to store references; one chosen manually during file insertion and the other by
defining a property of the field itself.
Figure 10-2. The check box option to store a reference instead of copying the entire file
When this option is selected, the container field will display the document as if it is stored within the
database, depending on the type of file and layout settings of the field. However, it will have stored only a
small amount of text within the field that points to the file in whatever directory it is stored.
This helps to maintain a lean database since the textual reference to the file is minuscule in size.
However, it has some serious drawbacks that need to be considered. Most notably, if the document being
referenced is moved to a new folder directory, the field will no longer be able to locate it and will display a text
message indicating that the file cannot be found. Also, if one user of a networked database inserts a reference
to a document that is stored locally on their computer or on a server location to which other users don’t have
access, other users will see the same error.
When references point to files in a static server location that every user of the database has equal access
to, this method will work fine.
236
Chapter 10 ■ Managing Containers
■■Note If a database file is renamed, the default base directory will not automatically update the folder name
to match. This can be done manually.
237
Chapter 10 ■ Managing Containers
From this tab, you can create, edit, and delete base directories. You can initiate a transfer of documents
using the Transfer Data button, which becomes highlighted after a field’s assigned base directory is changed
and documents are detected in the old location (see “Changing a Field Container Settings” later in this
chapter).
This window contains a single text area into which you can either type a directory path or drop a folder
to automatically insert its path. A path must be formatted as shown in the examples (Chapter 6, “Specifying
File Paths”).
When finished, click OK to save the path or Cancel to close without saving or creating the new base directory.
238
Chapter 10 ■ Managing Containers
■■Note FileMaker will not delete the actual folder, just the reference to it in the base directory list.
Once the Generate and store thumbnails for images check box is selected, FileMaker will
automatically begin generating and displaying a thumbnail for images when a layout attempts to display
them. There are two storage options:
• Permanent storage — This option will cache thumbnails both on-disk and in-memory,
with the on-disk portion retained when the database is closed.
• Temporary storage — This option will cache thumbnails in-memory only.
When the database is closed, the cache is discarded.
239
Chapter 10 ■ Managing Containers
Select the Store container data externally checkbox to activate managed external storage.
The relative to pop-up menu contains a list of all the directories defined in the Manage Containers
dialog with the first in the list selected by default. Select one to specify which base directory will be used to
store documents for the container field.
Once the directory is selected, there is a choice between two types of storage methodology: secure or open.
240
Chapter 10 ■ Managing Containers
■■Caution When more than one field uses the same base directory, each should be assigned a unique
subdirectory.
While Secure storage automatically handles duplicate file names, with open storage your choice of a
subdirectory may need to take this into consideration if similarly named files will be placed into a field for
different records. To protect against this, click the adjacent Specify button and define a subdirectory with a
dynamic calculation formula that includes a unique field, such as a serial id like this:
This will ensure that each file placed in that field for any record is stored in its own subdirectory and
that no naming conflicts will ever occur.
241
Chapter 10 ■ Managing Containers
Figure 10-7. The Container Data Transfer dialog informs you that documents need to be transferred to, from,
or between managed directories
This dialog lists all the container fields that have been changed. Selecting a field from the list will display
that field’s new destination settings, indicating the type of storage and new base directory. To immediately
transfer the documents to their new base directory, click Transfer. If you close instead, these changes will
be retained in a queue and can be transferred later with the Manage Containers dialog Transfer Data
button, which becomes enabled any time there are pending transfers in the queue.
Summary
In this chapter, we discussed the various methods of managing containers and the ramifications of different
document storage methods.
242
CHAPTER 11
A value list is a carriage-return delimited group of unique text values that can be assigned to layout objects
to give users a fast and reliable method of entering standard or frequently used information into a field in a
consistent and error-free manner. With only one exception, value lists are essentially context insensitive so a
list can be generated from any table occurrence regardless of the current layout context.
Lists can be defined to contain static, predefined values or values dynamically compiled from the
contents of a field gathered directly from a table or through a relationship.
This chapter covers the following topics:
• Using value lists
• Exploring the value list interface
• Creating value lists
2 3 4 5 6 7
244
Chapter 11 ■ Managing Value Lists
6.
Cancel — closes the dialog without saving changes after presenting a warning.
7.
OK — saves changes and closes the dialog.
■■Tip As of FileMaker Pro 16, you can copy and paste value lists within a file or between two files.
245
Chapter 11 ■ Managing Value Lists
5.
Click the OK button to save the changes.
246
Chapter 11 ■ Managing Value Lists
Once you have another file with at least one value list entered, open the Manage Value Lists dialog in
the file that will use it and then follow these steps:
1.
Click the New button. This will open the Edit Value List dialog.
2.
Enter a name for the value list.
3.
Select the Use value list from another file radio button.
4.
If you have already defined the other database as an external file source, it will
show up in the first pop-up menu. If not, you will need to define that now by
selecting Add FileMaker Data Source from that menu. In the Open File dialog,
locate and select the other database and click OK. This will add the file to the list
of external data sources and add it to the pop-up menu.
5.
Once the file has been selected from the first pop-up menu, the Value list pop-
up menu below will become activated. From this menu, you can select any of the
value lists in the external file, as shown in Figure 11-4.
Figure 11-4. The value list menu displaying all the lists defined in an external database file
6.
Click the OK button to save the changes.
247
Chapter 11 ■ Managing Value Lists
Create a new value list, assign it a name, and select the Use values from field radio button. This will
automatically open a Specify Field dialog, shown in Figure 11-5.
1 2
4
5
The top portion of the dialog contains controls for specifying which field(s) will be used to generate
the value list. The lower portion contains settings that control which values are included and how they are
sorted and displayed.
1.
Use values from first field — This combination of a table occurrence pop-
up menu and corresponding field list allows the selection of the primary field
that will be used to generate values for the list.
2.
Also use values from second field — Optionally, a value list can be a
generated from a combination of two fields by checking this box and selecting
another table occurrence and field. The second field, which can be in the same
table as the first or a related one, is used for display purposes only on the list
of values and is not entered in a field when the user selects a value. The most
common example of a use for this feature is when the first field uses a serial
number field to generate a list of record ids that can be selected for placement
into a field when assigning one record to another. By choosing a second field,
the list will include a descriptive component so the user knows what they are
selecting even though the serial number is what will be entered in the field. For
example, if the first field contains 052136 and the second field contains a name
John Smith, it will show up in the value list as a combination of the two: 052136
John Smith. The user looks at the second field to identify the record they are
selecting while the serial number from the first field is what is entered in the field
when they do so.
248
Chapter 11 ■ Managing Value Lists
3.
These two radio buttons control which values are included. The choices are:
a.
Include all values — Choosing this option will generate a list of unique
values from the selected field for all records in the table.
b.
Include only related values starting from — Choosing this option will
generate a list of unique values from the selected field for only those records
related through the context of a table occurrence you select from the adjacent
pop-up menu. This provides the ability to create a contextual value list that
changes values depending on which record a user is viewing (see “Creating
Conditional Lists,” this chapter).
4.
Show values only from second field — When enabled, this option will hide
values from the first field and only display values from second field. However,
when the user selects a value, the value from the first field is still entered. For
example, when the first field contains a serial number and the second field a
name, the user only sees the name and makes their selection, but the serial
number is entered in the field they are editing.
5.
Sort values using — When generating a value list from two fields, these radio
buttons allow you to control which field will be used to sort the list. These are
disabled and set by default when the list doesn’t use two fields or when the Show
values only from second field option is selected.
6.
Resort values based on — This check box activates an adjacent pop-up menu
allowing the selection of a language by which the values should be sorted. This
is especially useful when using languages where the dictionary sort order is
different from the indexed sort order, like languages that distinguish between
characters with and without diacritical marks in a dictionary sort but not in an
index sort. For more information on the implications of this setting, consult the
FileMaker documentation.
249
Chapter 11 ■ Managing Value Lists
In each of these cases, the value list must show every available record in the other table giving the user
the option to choose the one that should be assigned. Such a list would be configured using the Include all
values radio button and selecting the desired field(s) from the primary occurrence of the table. For example,
a value list in the Learn FileMaker database named Company All would be configured as shown in shown
in Figure 11-6.
Figure 11-6. A value list configuration that will show all company records
Once saved, this value list can be assigned to a field as a pop-up menu in any table. For example, in
the Contact table, the Contact Company ID field is used to store a foreign key that connects a contact to a
company through the Contact | Company relationship. So, to allow a user to quickly enter the Record ID for
a company, the value list can be assigned to that field as a pop-up menu on the Contact Form layout.
When the user clicks on the field, a list of every company will be displayed. Because the first field is the
Record ID, a selection will cause the ID of the company to be entered in the field, thereby establishing the
foreign key and connecting the two records.
250
Chapter 11 ■ Managing Value Lists
251
Chapter 11 ■ Managing Value Lists
Figure 11-7. The new relationship that will be used to pull values into a conditional value list
Next, create a new value list, as shown in Figure 11-8, which uses the new related occurence to generate
a conditional list of active companies.
1 2
Figure 11-8. The new value list that will generate a list of active companies using the new relationship
252
Chapter 11 ■ Managing Value Lists
Once saved, this value list can be assigned to the Contact Company ID field on a Contact layout as the
source for a pop-up menu and it will display a list of only the active companies (Chapter 30).
■■Note If using a secondary field when generating the conditional list, only the second field needs to be
generated from a conditional calculation.
To create a calculation-driven conditional value list that provides a result identical to the previous
example, follow these steps:
1.
Create a new calculation field named Company Active ID that returns a text
result and has a formula of:
253
Chapter 11 ■ Managing Value Lists
2.
Create a value list that uses the new calculation field for the second field and
choose Include all records, as shown in Figure 11-9.
Figure 11-9. The new value list that will generate a list of active companies using the new calculation field
The result will be a conditional value list that can be used from any layout context, regardless of the
source table and without a relationship between that table and the Company table.
Summary
In this chapter, we discussed how to define value lists from the perspective of the data structure.
254
PART III
Writing Formulas
A calculation formula is an equation made up of one or more text statements expressing operation(s) that
will be performed to manipulate values and arrive at a result. Relationships add to the basic data framework
by allowing for the interconnection of tables and fields. Formulas unlock another level by allowing the
manipulation of the information stored within that structure.
Formulas can be written to analyze, compare, concatenate, condense, convert, expand, format, parse,
replace, or summarize any of FileMaker’s supported data types. They can range in size from a simple
mathematical equation to an extremely complex collection of interrelated expressions and nested logical
clauses. The only limitation is that a single formula cannot exceed FileMaker’s limit of 30,000 characters.
In this chapter, we will discuss the following topics:
• Introducing formulas
• Defining formula components
• Exploring the calculation interface
• Writing formulas
• Adding calculations to the Learn FileMaker file
Throughout this chapter, use the Sandbox table and layout in the Learn FileMaker database to
experiment with the example formulas mentioned in this chapter.
Introducing Formulas
Formulas are written in a Specify Calculation dialog window, like the one shown in Figure 12-1.
Figure 12-1. A Specify Calculation dialog window for defining a calculation field formula
These dialogs are found throughout the FileMaker development environment in the locations listed
in Table 12-1. Generally, any of the following interface elements indicate that a calculation formula can be
entered:
• An Options button.
• A Specify button.
• A Fx icon button.
• A pencil icon button.
• A Specify... option at the bottom of a pop-up menu.
258
Chapter 12 ■ Writing Formulas
Table 12-1. Places where formulas are used to dynamically calculate a value within a database
259
Chapter 12 ■ Writing Formulas
Once saved, a formula remains idle until it is called when some process requests that it evaluate and
produce a result. A call may come because of the following:
• A layout attempting to render a calculation field.
• The execution of a script that contains a step with a calculation.
• A user typing into a field with an auto-enter calculation.
• A call from one calculation that uses another in its formula.
When called, the formula’s statement is evaluated, which means that the code is converted into a result
by working through each expression’s operations from left to right based on specific operator precedence.
Formulas are evaluated within a context to allow local and related fields to be accessed from the
perspective of a specific table occurrence. A formula that provides a value for an interface element will use the
context of the table occurrence of the layout upon which the object is being rendered. A formula used in a field
definition requires a manually selected context of any table occurrence for the table in which the field exists.
The formula’s result is a single value that will be returned to whatever process requested the execution
of the formula. A calculation field’s formula displays the result on a layout as if it were data typed into the
field. The Set Variable script step places the result of its formula into a variable. The type of object that
called the formula determines the destination or use of the result.
If the formula is unable to create a result due to an error, it will return a question mark. For example, if
a formula is using a field that has been deleted or is inaccessible from the current context, the formula may
return an error. Also, using a custom function that has been deleted or returning a data type inconsistent
with the expectations of the calling process will return an error.
Comments
A comment is a text string inserted into a formula that is ignored when the code is evaluated. Comments
are intended to act as integrated documentation for developers and can be beneficial as a reminder both to
yourself and to others who may see your code in the future. Comments can provide details about how the
formula works, how to use it, and to list recent changes and any other information you may think necessary
to embed in your code. A comment may be placed at the top of the formula or between different statements.
There are two styles of comment available; multi-line (C style) and single-line (C++ style).
260
Chapter 12 ■ Writing Formulas
Multi-Line Comment
A multi-line comment uses an initiating and terminating symbol to indicate the start and end of the
comment and can, therefore, comment out multiple lines of text. To enter a multi-line comment, use a
/* to indicate the start of the comment and */ to indicate the end of the comment. Any text between these
two symbols will be ignored by FileMaker when the formula is evaluated.
/*This is a comment
The comment continues on additional lines
Until you terminate it*/
If desired, extra carriage returns can be added to make the text more readable.
/*
This is a comment
Single-Line Comment
A single-line comment uses a symbol at the beginning of a paragraph, commenting out any text between it
and a next carriage return.
To enter a single-line comment, place two forward slashes at the start of the line or at the point on a line
where a comment should begin. Any text to the right of these symbols but before the next carriage return will
be ignored by FileMaker when the formula is evaluated.
// This is a comment
// To continue on a second line you must use another set of symbols
2 + 2 // This comment starts in the middle of a line, after a formula
Throughout this book, the result of a formula will be included after the code as a comment. For
example:
Constants
A constant, sometimes referred to by developers as a literal, is a static, unchanging value that is literally
typed into a formula. The value can be any of FileMaker’s data types: text, number, date, time, or timestamp.
A quantity, city name, event date, and start time are all examples of constants when they are typed directly
into a formula as part of the formula rather than being represented dynamically by a variable or field.
Numeric constants can be typed directly into a formula. A text constant must be contained within
quotation marks so that it is interpreted as a literal value instead of as a field or function name. Date and
time constants must be typed within quotation marks and, to be recognized and treated as something other
than text, they may need to be converted into date and time objects using a built-in function: GetAsDate,
GetAsTime, and GetAsTimestamp (Chapter 13).
261
Chapter 12 ■ Writing Formulas
The following are examples of each type of constant, as they might appear in a formula:
150
"New York"
"1/15/2017"
GetAsDate ( "1/15/2017" )
"10:15:00"
GetAsTime ( "10:15:00" )
"1/15/2017 10:15:00"
GetAsTimestamp ( "1/15/2017 10:15:00" )
Field References
A field reference is a dynamic pointer to a field. References inform FileMaker to extract a value from a
specific field, through a specific context, and to use that value in place of the reference when evaluating the
expression.
Depending on the type of calculation and the location of the field relative to the evaluation context of
the calculation formula, a field reference is considered either local or related and can be stated as either the
name of the field or the name of the table occurrence and field.
A local field is a field that exists within the table of the current context. For a calculation field, the
current context is the table containing the field. For a formula used in a custom menu, script step, custom
function, etc., the context will always be the source table of the table occurrence assigned to the layout
displayed in the current window at the time of evaluation.
A local field reference inside of a calculation field’s formula can take the form of only the name of the
field. For example:
First Name
Project Name
Invoice Number
All other field references must include the name of the table occurrence preceding the field name and
separated by two colons. The addition of the table occurrence informs FileMaker of precisely which field you are
referring to and allows it to attempt to acquire the value through the appropriate relational conduit.
For example:
Contact::First Name
Project::Project Name
Invoice::Invoice Number
262
Chapter 12 ■ Writing Formulas
to manually change every field reference each time a table or field name is changed. Therefore, it is highly
recommended that all field references remain dynamic.
To illustrate the difference between a dynamic field reference and a constant field reference, consider
the example below, which shows two methods of accessing a field value using the GetField function
(Chapter 21). The first is a text-based reference, hard-coded into a static text string, while the second is a
dynamic reference. Once set up, they each return the identical field value.
However, when the name of the field is changed from First Name to NameFirst, only the second will
automatically update since it is a dynamic reference instead of static text. Since the first example no longer
refers to an actual field, it will evaluate to an error.
A dynamic reference converted this way can be used in other expressions that require a text-based
reference without a concern for future name changes.
Functions
A function is a predefined, named formula that may accept parameters and is evaluated to return a single
result. Functions are like subroutines in other programming languages. They allow a subset of functionality
to be offloaded to a process outside of the current formula and make possible efficient organization of code.
Within FileMaker, there are two kinds of functions: Built-in functions (Chapters 13-24) and Custom functions
(Chapter 25). In this section we will briefly illustrate how to call any function from within a formula.
FunctionName
■■Note The capitalization and lack of spacing shown in this example are used consistently for FileMaker’s
built-in functions but are not a requirement for custom functions. Although not required, for the sake of
consistency and readability, you may want to adhere to this convention for your custom functions.
263
Chapter 12 ■ Writing Formulas
■■Note Except for any limitations imposed by a specific function or by the nature of the data a parameter is
designed to accept, a parameter can accept data as a constant, field reference, expression, variable, literal, or
even a nested function.
Parameters are listed after the function name, enclosed within a set of parentheses, as shown here:
FunctionName ( parameter )
If a function accepts more than one parameter, they are listed in order, separated with semicolons after
the function name, enclosed within a set of parentheses, as shown here:
The value inserted into a parameter can be an expression. In this example, the one parameter is made
up of two fields being multiplied together, the result of which will be sent to the function as the single
parameter:
Optional Parameters
Some built-in functions offer optional parameters that can be used or ignored as needed. When inserting a
function call into a formula, FileMaker will surround optional parameters with braces as shown in this example:
In this case, the braces indicate that parameter1 is required while parameter2 and parameter3 are
optional. Optional parameters that you won’t be used can be removed by deleting them along with the
braces. If they will be used, only the braces should be removed. This example illustrates the pattern of a
single function call without optional parameters and a second call to the same hypothetical function with
the optional parameters included:
FunctionName ( parameter1 )
FunctionName ( parameter1 ; parameter2 ; parameter3 )
264
Chapter 12 ■ Writing Formulas
Operators
An operator is a symbol used to express a type of operation within a formula. The most familiar examples
are mathematical operators where the plus symbol in 2 + 2 is the operator. FileMaker has many different
operators, each executing in an order of precedence.
Defining Operators
FileMaker has four categories of operators:
• Comparison operators
• Logical operators
• Mathematical operators
• Text operators
■■Note For clarity, most of the examples provided in this section use operators with formulas containing only
constants. However, they can certainly be used with any combination with other formula components.
Comparison Operators
A comparison operator is a symbol used to construct an equation that compares two values, either a literal
value or the evaluated results of two expressions. The result of an expression using a comparison operator
will be a true or false Boolean value, represented respectively by a 1 or 0.
Equal To
An equal to symbol is used to compare two values for similarity. The equation will evaluate to true if the
values are identical and false if they are not.
265
Chapter 12 ■ Writing Formulas
Not Equal To
Comparing two values for dissimilarity can be performed using either a not equal to symbol or a less than
and greater than symbol side by side. An equation will evaluate to false if the values are identical and true if
they are not, as demonstrated in these examples:
■■Tip The ≠ symbol can be created by typing an equal sign while holding the Option key on macOS.
Greater Than
A greater than symbol is used to compare the relative alphabetical or numerical positions of two values. The
equation will evaluate to true if the value on the left is greater in position compared to the value on the right.
266
Chapter 12 ■ Writing Formulas
■■Tip The ≥ symbol can be created by typing a greater than symbol while holding the Option key on macOS.
Less Than
A less than sign < is used to compare the relative alphabetical or numerical positions of two values. The
equation will evaluate to true if the value on the right is greater in position than the value on the left.
267
Chapter 12 ■ Writing Formulas
■■Tip The ≤ symbol can be created by typing a greater than symbol while holding the Option key on macOS.
Logical Operators
A logical operator is a keyword used to build compound conditions into a formula by joining two or more
separate expressions into a single expression or, in one case, to negate a single expression, thereby reversing
a Boolean result. The result of an expression using a logical operator will be a Boolean.
AND
The AND operator is used to combine two separate Boolean expressions into a combined equation that will
evaluate to true only if the result of both expressions are true.
OR
The OR operator is used to combine two separate Boolean expressions into a combined equation that will
evaluate to true if the result of at least one of the two expressions is true.
XOR
The XOR operator is used to combine two separate Boolean expressions into a combined equation that will
evaluate to true if the result of only one of the two equations is true. If both equations are true, it will return
false.
NOT
The NOT operator is a unique logical operator that will negate the result of any expression to its right, thereby
reversing the Boolean result of that expression. If an expression evaluates to true, putting this operator in
front of it will reverse it to return false.
268
Chapter 12 ■ Writing Formulas
A similar reveresal can also be achieved by the following statement, which will return true if the
expression in parenthesis evaluates false.
■■Tip While the order of operator precedence should always be kept in mind, some developers prefer to
enclose the expression(s) after a NOT operator in parentheses to avoid any confusion and ensure the appropriate
result, especially with compound expressions.
Mathematical Operators
A mathematical operator is a symbol used to perform or control arithmetic computations with one or more
values or expressions. The mathematical operations can be performed not only on numbers but on other
data types such as dates, times, and timestamps.
Addition
The plus symbol is used to add the value on the right to the value on the left.
Subtraction
The minus symbol is used to subtract the value on the right from the value on the left.
100 – 50
GetAsDate ( "1/5/2017” ) - 2 // result = 1/3/2017
GetasTime ( "1:15:00" ) - 300 // result = 1:10:00
Multiplication
The multiply symbol is used to multiply the value on the left by the value on the right.
100 * 50
Division
The division symbol is used to divide the value on the left by the value on the right.
100 / 50
269
Chapter 12 ■ Writing Formulas
Raising to a Power
The power of symbol is used to raise the value on the left to the power of the value on the right.
100^2
Precedence
A set of parentheses is used to change the order of evaluative precedence (discussed later in this chapter).
FileMaker will evaluate formulas from left to right after first evaluating expressions that are enclosed
within parentheses, working from the inside out and based on an order of precedence. Although these two
equations perform the same mathematical operations on the same numbers in the same order, the results
are drastically different due to the control of precedence imposed with parentheses:
Text Operators
A text operator is a symbol that is used to construct an equation that combines text items into a single item
and performs other text-related functions.
Quotations Mark
A pair of quotation marks is used to indicate a literal text constant. Text entered into a formula without
quotation marks will be interpreted as a field, function, or variable name. Date and time constants must be
enclosed in quotation marks.
"John"
"1/15/2017"
Concatenate Text
The ampersand symbol & is used to join two text values into a single value.
Carriage Return
The paragraph carriage return symbol is used to insert a carriage return into a text value.
■■Tip The carriage return symbol can be created by typing a 7 while holding down the Option key on macOS.
270
Chapter 12 ■ Writing Formulas
Backslash
The backslash symbol \ is used to make an operator character be used literally instead of as an operator. For
example, a backslash+quote inserted at the end of this example can represent 5 inches as a text string with
the extra quote mark treated as part of the resulting text value.
Without the backslash, FileMaker will interpret the formula as having a syntax error and not allow it to
be saved.
"5""
Reserved Name
Although it is not advisable to do so, you can use a reserved function name or keyword as a table name or
field name. However, when doing so and using these in a formula, FileMaker must be informed of the fact so
it interrupts the information as the value you intend rather than the function or keyword it also represents.
This is accomplished by wrapping the name within curly brackets with a preceding dollar symbol.
The following will be interrupted as a field or table name rather than an AND operator:
${AND}
271
Chapter 12 ■ Writing Formulas
Reserved Words
A reserved word is a word, term, or symbol that is used by FileMaker for function names, predefined
parameters, operators, and to construct SQL statements. These should not be used as names for tables,
fields, custom functions, and other objects to avoid problems when referring to these objects in a formula.
FileMaker reserves the words shown in Table 12-2.
+ - * / ˆ &
= ≠ < > ≤ ≥
( , ; ) [ ]
" :: $ }
FileMaker reserves SQL keywords, shown in Table 12-4. To avoid syntax errors with the ExecuteSQL
function, avoid these as well.
272
Chapter 12 ■ Writing Formulas
273
Chapter 12 ■ Writing Formulas
Table 12-4. (continued)
Variables
A variable is a developer-named letter, word, or phrase that can store and be used in place of a value in a
calculation formula and elsewhere in the development environment, including some less-obvious places
such as:
• Script steps that include a formula.
• File paths dialogs.
• Find request criteria dialogs.
• On layouts as merge variables.
• Data source dialogs.
Types of Variables
FileMaker has three different variable types, each with different naming requirements and scope:
• Local Let statement variables
• Local script/function variables
• Global database variables
274
Chapter 12 ■ Writing Formulas
The last two have a specific name prefix requirement, a single and double dollar sign respectively. In
addition, these general naming guidelines for all variables should be considered:
• Avoid keywords and field names to avoid confusion.
• Be concise; keep the name as short as possible to save space and avoid clutter.
• Be descriptive; make sure the name is clear and indicates what data it will contain.
• Be consistent in case; choose “camel case” (variableNameExample), dot-delimited
(variable.name.example), underscore delimited (variable_name_example) or some
other format and then stick with it throughout the database.
x
data
firstName
first_Name
dateToProcess
table.name
Since these variables are temporary and only accessible from within the confines of the Let statement
in which they are defined, there is no fear of them conflicting with variables in other formulas or within
the same formula outside of the Let statement containing them. Therefore, to maintain consistency,
standardized names can be reused from one formula to the next without concern about them overwriting
each other.
275
Chapter 12 ■ Writing Formulas
FileMaker requires that local variables be named with a single dollar symbol prefix. Beyond that, the
name can be as short as a single character or a lengthy, multi-word phrase and can use any of a variety of
delimiters. For example:
$data
$firstName
$recordNumber
$dateToProcess
$date.to.process
$date_to_process
Since these variables are shared within a script but not between scripts, there is no fear of them
conflicting with variables in other scripts. For consistency, standardized names can be reused from one
script to the next without concern about them conflicting with each other.
Local variables can be monitored in the Data Viewer during the execution of a script (Chapter 36).
■■Caution Local variables with the same name can conflict when a script calls a custom function
multiple times.
■■Tip To avoid clutter and confusion, global variables should not be overused. Limit their use to information
that is truly required universally within the file due to widespread use by scripts and calculations. Avoid using
global variables to pass information between scripts by using parameter passing instead (Chapter 34).
276
Chapter 12 ■ Writing Formulas
FileMaker requires that global variables be named with a double dollar symbol prefix. Beyond that,
names can be as short as a single character or a lengthy, multi-word phrase and can use any of a variety of
delimiters. For example:
$$data
$$firstName
$$recordNumber
$$dateToProcess
$$date.to.process
$$date_to_process
Since these variables are global, they must each be uniquely and carefully named to avoid confusion
and conflicts with other global variables in the same file. However, since they are not shared between files,
standardized names can be reused from one database to the next without concern about them conflicting
with each other.
Global variables can be monitored in the Data Viewer (Chapter 36).
277
Chapter 12 ■ Writing Formulas
3 4 5
2 1 7
8 11
12
9 10
While these controls will be explained in more detail as we create some example formulas, let’s take a
brief tour to become familiar with these controls:
1.
Formula Text Area — This central text area is where the calculation formula is
written. You can type, drag-drop, copy-paste, or insert content by clicking on the
panels to the left and right.
2.
Field Selector Pane — These controls assist with the insertion of a selected field
reference into the formula.
3.
Context Indicator — When defining a field, formulas require the selection of a
table occurrence to act as the context from which the formula will be evaluated.
If only one occurrence is available for the table the menu will be disabled. If
the formula evaluates from the context of the current window, the menu will be
hidden.
4.
Operators — Click on any of these buttons to add the corresponding operator at
the insertion point within the text of the formula.
5.
Help Icon — Click for the documentation web page of information about this
window and its functions.
278
Chapter 12 ■ Writing Formulas
6.
Functions Pane Toggle Button — Click this icon to toggle the visibility of the
Functions Pane below.
7.
Functions Pane — These controls allow functions to be selected and added into
the formula.
8.
Calculation Result Data Type — Field definition formulas require selection of
the resulting data type from this pop-up menu; other formulas mandate a data
type based on the object or property to which the formula pertains. For example,
button labels must be text, layout number must be a number, etc.
9.
Number of repetitions — Field definition formulas can be made repeating by
entering a number into this text area.
10.
Do not evaluate checkbox — Checking this box will cause the calculation to not
evaluate and automatically return no value if every field referenced within it is
empty.
11.
Storage options — This button opens a dialog containing indexing and other
storage options for calculation fields.
12.
Buttons — Click the Cancel button to close the window without saving changes.
Click OK to save changes and close the window.
Writing Formulas
Formulas can contain any combination of components and range greatly in complexity. Before attempting
to write your first masterpiece of coded wizardry, take a moment to work through some simple examples
that demonstrate the basic concepts involved.
Constant-Only Formula
A constant-only formula is a formula that evaluates to a literal value without performing any actual
operations. It is basically a statement containing a single value that will evaluate to a result of the same value.
These have a practical value as a way of storing static information such as a current tax rate or value(s) used
as a relationship match field to connect to a subset of related records of a certain type. For now, it will serve
as the most basic example to get us started writing a simple formula.
To create your first constant-only formula, enter the value below and select a calculation result data
type of “text.”
"Hello World"
279
Chapter 12 ■ Writing Formulas
The dialog should now look like the one shown in Figure 12-3.
Click the OK button to save the formula. The Example Calculation field on the layout should now
display the text “Hello World” on every record. It is the same on each record because the formula returns
a static value. For it to vary from one record to the next, the expressions must contain some variable
components such as field values that change from one record to the next.
"Hello World
When you then click the OK button, FileMaker should display the error dialog message shown in
Figure 12-4. When a syntax error is detected, FileMaker will not allow you to save the formula until it is
correctly formatted.
280
Chapter 12 ■ Writing Formulas
By contrast, a result error is a resulting question mark that indicates a problem with the formulas
settings or a component used within one or more of its operations.
To illustrate this, restore the formula’s closing quote mark to eliminate the syntax error. Then change the
calculation result to date, time, or timestamp. FileMaker will let you save the formula because the syntax is
correct even though you have selected a result type inconsistent with the type of data (text) being returned
by the calculation. When you look at the field on a record, the result will be displayed as a question mark.
Try each data type and see how the results vary.
"Hello World"
// result as text = Hello World
// result as number = Hello World
// result as date = ?
// result as time = ?
// result as timestamp = ?
// result as container = Hello World
Three of the data types will result in an error. However, even though the number and container results
appears to display the correct information, the data in the field will not necessarily behave the way you
might expect when searching, sorting, or using the information in other formulas. FileMaker will assume
the data is the type you specify in the calculation result setting and this could cause more obvious problems
elsewhere in both behavior and performance.
■■Caution Troubleshooting error results is a necessary skill as databases develop and begin to involve more
and increasingly complex formulas.
281
Chapter 12 ■ Writing Formulas
The global storage and indexing features work the same as they do for Entry fields (Chapter 8). However,
there is an additional option for indexing; Do not store calculation results. This feature is used to force
a calculation to never automatically index results and instead to always recalculate a result anytime the field
is accessed or displayed.
To illustrate the importance of this feature, restore the formula in the Sandbox::Example Calculation
field to the original example — a result type of Text and the following formula:
"Hello World"
Save the formula and confirm that the field displays correctly on records viewed on the Sandbox layout.
Once confirmed, open the formula again and type two forward slashes in front of the text to convert it into a
comment. Now the formula should look like this:
// "Hello World"
Without making other changes, save the formula and again view it on the Sandbox layout. Don’t be
surprised if it still displays the value “Hello World” as if nothing changed. Select the Record > New Record
menu and notice that the new record will correctly display a blank value in the field.
The reason for this is the indexing setting for the calculation field. While other field types use index
settings primarily to pre-process data in a way that will speed up searches and help establish relational
connections, a calculation field may not refresh its result when nothing else triggers it to reevaluate,
especially when the index settings forbids it.
If you change and save a formula significantly, it will prompt every record to refresh the results. For
example, change the formula for the Sandbox::Example Calculation field to a completely different text
constant and when you save, every record will update to display the new value. However, as the example
above demonstrates, FileMaker doesn’t always force a simple calculation to update when its text constant is
commented out or some other minor change is made. To make our simple example work correctly, follow
these steps to turn indexing completely off for the calculation field:
1.
Open the formula.
2.
Click the Storage Options button.
3.
Check the Do not store calculation results check box.
4.
Click OK to close the Storage Options dialog.
5.
Click OK to save the formula.
This simple example isn’t practical and not representative of the kinds of challenges you will face with
indexing. However, there will be many times when you need to adjust the index settings. It will take you
some time to gain experience to know what will force an update or not. For example, a formula that uses
built-in functions to return contextual values such as the number of records in the found set or the current
record number within the found set will require the Do not store calculation results selected to
update as you would expect when the user navigates through a found set. By contrast, formulas that include
references to fields will update automatically when those field values are modified, even when indexing is
allowed.
282
Chapter 12 ■ Writing Formulas
Using Auto-Complete
When typing the examples in this chapter so far, you may have noticed FileMaker presenting an auto-complete
suggestion interface that continuously filters based on the word you are typing. In the example shown in
Figure 12-6, after typing just the letter “E,” a list of available components is presented including a mixture of
every built-in function, custom function, and field that contains the letter “E”.
Figure 12-6. An example of the auto-complete function when typing into formulas
As you continue typing — “Ex,” “Exa,” “Exam” — you will see the list continuously filter the list down
until you see only a list of our example fields.
When the auto-complete list appears, you have the option to ignore it and continue typing or to use it
to automatically insert a value from the list. To do so, select the desired item and initiate its entry into your
formula.
To select an item from the auto-complete list, you can either:
• Use the cursor to scroll the list and click directly on an item.
• Navigate up and down the list using the Up and Down arrow keys.
• Continue typing enough text until the desired item is at the top of the list and
selected.
As your selection changes within the list of available components, the text in the shaded area at the
bottom will update to display a brief description of the current selection. Function and field descriptions will
appear here.
Once you have selected the desired component, you can enter it into the formula by either typing Enter
or double-clicking on it in the list.
■■Tip For the fastest entry method using auto-complete, skip the cursor and arrow keys. Instead, type just
enough of the component’s name until it appears at the top of the list and then type Enter.
283
Chapter 12 ■ Writing Formulas
2 3
The following controls are available to aid in the location and selection of a field:
1.
Table occurrence menu — The pop-up menu at the top will default to the current
context’s table. For a calculation field, this means the table containing the field.
When working with formulas for script steps or other interface components, this
will be the table of the layout in the current window.
2.
Filter search field — This text area is used to enter a search value that will narrow
the list of fields.
3.
Field sort menu — Click this icon to open a pop-up menu of sort options for the
list of fields below. The available choices are the same as the sort options in the
Fields tab of the Manage Database dialog:
a. Creation order
b. Field Name
c. Field Type
d. Custom Order
4.
Field list — This list displays the fields for the selected table occurrence that
match any search filter criteria entered, sorted in the order indicated by the sort
menu.
Once a field is selected, double-click it to add it to the formula at the insertion point.
284
Chapter 12 ■ Writing Formulas
1 2
The following controls are available to aid in the location and selection of a function:
1.
Filter search field — This text area is used to enter a search value that will narrow
the list of functions.
2.
Function option menu — Click this icon to open a pop-up menu of options for
the list of functions below. There are choices:
• Show and organize All functions by name.
• Show and organize All functions by type.
• Show one selected category of functions sorted by name.
3.
Function list — This list displays either all installed functions or those matching
the sort/category menu selection.
285
Chapter 12 ■ Writing Formulas
Once the function is selected in the list, double-click it to add it to the formula at the insertion point. For
a complete reference list of all available built-in functions, see Chapters 13-24.
100 50 150
200 75 275
Figure 12-9. An illustration of a simple repeating calculation, manipulating values in other repeating fields
In this example, the calculation field’s formula would be defined to add the numbers together:
This formula will be automatically applied to each set of repetitions, and the resulting value for each is
placed into the corresponding repetition in the calculation field.
Non-Repeating Number 50 60
10 75 85
225 235
286
Chapter 12 ■ Writing Formulas
For the formula to successfully add the value in the non-repeating field to each value in the repeating
field and generate three results, one in each repetition, the calculation formula would be defined as follows:
This essentially duplicates the single value in the non-repeating field value into three separate virtual
repetitions, each populated with the same value, as if it were a repeating the same number of times as the
other field(s) involved in the calculation.
(150+50)/25
$FirstName&$Space&$LastName
Get(CurrentDate)
With space added, these will function the same, but are now easier to read.
( 150 + 50 ) / 25
$FirstName & $Space & $LastName
Get ( CurrentDate )
287
Chapter 12 ■ Writing Formulas
Adding spaces between components helps a little, but even this short example is still somewhat visually
hard to follow.
Let ( [ data = Input ] ; data & Case ( data ≠ "" ; " (" & Length ( data ) & ")" ) )
In addition to the spaces between components, by adding tabs and carriage returns, the formula is
expanded in away that separates and highlights the inner portions of the two statements.
Let ( [
data = Input
] ;
data &
Case (
data ≠ "" ; " (" & Length ( data ) & ")"
)
)
The benefit of this approach becomes even more apparent when the formula begins to grow. Just
imagine the example below expressed as a continuous string without spaces, tabs, or returns.
Let ( [
data1 = input1 ;
data2 = input2 ;
data3 = input3 ;
data4 = input4 ;
data5 = input5 ;
] ;
Case (
data1 ≠ "" ; data1 & " (" & Length ( data1 ) & ")" ;
data2 ≠ "" ; data2 & " (" & Length ( data2 ) & ")" ;
data3 ≠ "" ; data3 & " (" & Length ( data3 ) & ")" ;
data4 ≠ "" ; data4 & " (" & Length ( data4 ) & ")" ;
data5 ≠ "" ; data5 & " (" & Length ( data5 ) & ")" ;
)
)
288
Chapter 12 ■ Writing Formulas
The Substitute function can benefit greatly from indentation and carriage returns when it contains
numerous find-replace value pairs. This example shows a formula for a hypothetical statement where each
of five find-replace value pairs is on its own line, making the overall statement easy to view and edit:
Substitute (
input ;
[ find1 ; replace1 ] ;
[ find2 ; replace2 ] ;
[ find3 ; replace3 ] ;
[ find4 ; replace4 ] ;
[ find5 ; replace5 ]
)
289
Chapter 12 ■ Writing Formulas
5.
Double-click on the Record ID field from the Company | Contact table
occurrence.
6.
Make sure the Calculation result type is Number.
7.
If the formula reads Count ( Company | Contact::Record ID ) click OK to close
the Specify Calculation dialog.
■■Note The examples provided in this chapter are relatively simple. More complex calculations will appear
throughout the remaining chapters.
Summary
In this chapter, we discussed the basics of writing formulas.
290
CHAPTER 13
Text Functions
Text functions are used to analyze, convert, combine, extract, and create text strings.
• LeftValues
• LeftWords
• Length
• Lower
• Middle
• MiddleValues
• MiddleWords
• NumToJText
• PatternCount
• Position
• Proper
• Quote
• Replace
• Right
• RightValues
• RightWords
• RomanHankaku
• Roman Zenkaku
• Serial Increment
• SortValues
• Substitute
• Trim
• TrimAll
• UniqueValues
• Upper
• ValueCount
• WordCount
Char
The Char function converts a number into its equivalent Unicode text character.
292
Chapter 13 ■ Text Functions
Code
The Code function converts a text value into an equivalent Unicode number.
Exact
The Exact function compares two values and determines if they are the same or not. The function is case sensitive
and looks for precisely the same characters unlike a simple comparison with the is equal to operator.
To see the how this function differs from the is equal to operator when comparing values of
different cases:
293
Chapter 13 ■ Text Functions
Comparing text constants to field contents, these examples assumes a record in a Contact database
with two fields: State containing a value of “NY” and “Age” containing a value of 21.
Filter
The Filter function removes any unwanted characters from a text value.
FilterValues
The FilerValues function removes out any unwanted values from a list of values.
294
Chapter 13 ■ Text Functions
Furigana
The Furigana function converts Japanese text into one of five different alternatives. For more information on
Japanese functions, see FileMaker’s documentation.
GetAsCSS
The GetAsCSS function converts formatted text into the Cascading Style Sheet (CSS) format, thereby
preserving the font, font size, font color and font style attributes.
Converting the text from a field, this example assumes a record in a Contact table with a field named
First Name that contains the name “John” where the font is “Arial,” the font size is 18 pt, the font style is
bold, and the font color is red:
GetAsDate
The GetAsDate function converts a text-based date into a date object to ensure proper results when
compared to or sorted with other dates.
295
Chapter 13 ■ Text Functions
Dates should always contain a four-digit year to ensure correct handling. However, this function will
handle dates with two-digit years with pretty good results if the intented four-digit year is either within the
next 30 years or the preceding 70 years from the current date. Outside of that range you may get unexpected
results if you don't use four-digit years. These examples assume a current date of January 5, 2017:
When a number is provided, it is used to calculate the number of days that have passed since January 1,
0001. For example:
GetAsNumber
The GetAsNumber function converts a text-based number value into a number object to ensure proper results
when compared to or sorted with other numbers.
When providing numbers as text, they are converted back into numbers. For example:
Here are some examples of converting values that contain non-numeric characters:
In some cases, relying on automatic filtering of non-numeric characters might not provide in a desirable
result. For example:
The examples below assume a value of “03” is contained in a text field called Qty. They show the
importance of converting text into numbers when comparing to other numeric values. Because of the
leading zero on the text-based number in the field, the two values don't appear to be the same (in the first
example) until the text is converted to a number (in the second example).
296
Chapter 13 ■ Text Functions
The examples below assume a value of “20” is contained in a text field called Qty. Since it is a text value,
20 will appear as a smaller value than 3 because the text is compared character by character rather than the
entire value compared as a number. Once converted to text, as shown in the second example, it evaluates
correctly.
GetAsSVG
The GetAsSVG function converts text to the Scalable Vector Graphics (SVG) format, which supports more text
formats than HTML so it may represent text more accurately in some cases.
The example below assumes a record in a Contact table with a field named First Name that contains
the name “John” where the font is “Arial,” the font size is 18 pt, the font style is bold, and the font color is red.
GetAsText
The GetAsText function converts a number, date, time, or timestamp expression or any field containing any
data type (including containers) into text.
No matter the type of data, it will be converted into a text string as seen in these examples:
297
Chapter 13 ■ Text Functions
A container field that contains a reference to an image file will return the metadata in the form of name,
size, and path of the file as shown in this example:
GetAsText ( Contact::Image )
// result =
size:191,175
image:Mark Munro.jpg
imagemac:/Macintosh HD/Users/admin/Desktop/Mark Munro.jpg
If the field contains an image rather than just a reference, the function returns the name of the image
file as shown in this example:
GetAsTime
The GetAsTime function converts a text-based time or timestamp value into a time object to ensure proper
results when compared to or sorted with other times.
Only text strings containing time values will be properly converted. For example:
GetAsTimestamp
The GetAsTimestamp function converts a text-based time or timestamp value into a time object to ensure
proper results when compared to or sorted with other times.
When the text contains full timestamp information, it is converted into the proper data format as shown
in this example:
298
Chapter 13 ■ Text Functions
If a date is provided without time information, the function returns a timestamp for midnight on the
specified date, as shown here:
If only a number is provided, the function returns timestamp for that number of seconds since
1/1/0001, as shown here:
GetAsURLEncoded
The GetAsURLEncoded function encodes text for use in a Uniform Resource Locator (URL) as follows:
• All style information is removed from the text.
• The characters are converted to UTF-8 format.
• Any characters that are not a letter or digit, or are in the upper ASCII range are
percent encoded, meaning they are converted to a percent symbol followed by the
hexadecimal value of the character (%HH).
GetValue
The GetValue function extracts a value from a list of values.
299
Chapter 13 ■ Text Functions
If the specified value is greater than the number of values in the list, an empty string will be returned, as
shown in this example:
Hiragana
The Hiragana function converts Katakana (Hankaku and Zenkaku) in text to Hiragana. For more information
on Japanese functions, see FileMaker’s documentation.
KanaHankaku
The KanaHankaku function converts Zenkaku Katakana in text to Hankaku Katakana. For more information
on Japanese functions, see FileMaker’s documentation.
KanaZenkaku
The KanaZenkaku function converts Hankaku Katakana in text to Zenkaku Katakana. For more information
on Japanese functions, see FileMaker’s documentation.
KanjiNumeral
The KanjiNumeral function converts Arabic numerals to Japanese Kanji numerals. For more information on
Japanese functions, see FileMaker’s documentation.
Katakana
The Katakana function converts Hiragana in text to Zenkaku Katakana. For more information on Japanese
functions, see FileMaker’s documentation.
Left
The Left function extracts a specified number of characters from the provided text starting from the first
character on the left.
300
Chapter 13 ■ Text Functions
When the number specified is greater than the number of characters in the text provided, the function
will return the original value, as shown in this example:
LeftValues
The LeftValues function extracts a specified number of values from a list of values starting from the first
value.
When the number specified exceeds the available values, the entire text provided will be returned, as
shown in this example:
LeftWords
The LeftWords function extracts a specified number of words from the text provided, starting from the first
word on the left.
The specified number of words will be returned with any punctuation that falls within the range, as
shown here:
LeftWords ( "Hello World. How are you?" ; 3 ) // result = "Hello World. How"
When punctuation falls at the end of the range, will not be included, as shown here:
LeftWords ( "Hello World. How are you?" ; 2 ) // result = "Hello World"
301
Chapter 13 ■ Text Functions
Length
The Length function counts the number of characters in a piece of text.
This example shows that odd results can be expected when providing non-text values:
Lower
The Lower function transforms a text string into all lowercase.
Middle
The Middle function extracts a specified number of characters from a specified position within a text string.
302
Chapter 13 ■ Text Functions
MiddleValues
The MiddleValues function extracts a specified number of values from a list of values starting from a
specified value.
Here is an example showing the extraction of two values from the middle of a list of values:
MiddleWords
The MiddleWords function extracts a specified number of words from the text provided, starting from a
specified word.
Here is an example of extracting two words from the middle of some text:
MiddleWords ( "Hello World. How are you?" ; 3 ; 2 ) // result = "How are"
NumToJText
The NumToJText function converts Arabic numerals to Japanese text. For more information on Japanese
functions, see FileMaker’s documentation.
PatternCount
The PatternCount function counts of the number of times a specific pattern of text appears in the text provided.
303
Chapter 13 ■ Text Functions
Remember that PatternCount looks for matches anywhere in the text provided, including as part of a
word or paragraph. When checking for the presence of a value in a list of carriage return-delimited values,
it is important to avoid partial matches like those returned by the PatternCount function. For example, the
following code will find two matches for “age” in the text provided. However, if we are looking for a match to
“age” as a value — as a single paragraph — those results are faulty.
To avoid this, one may use the cumbersome technique of including paragraph returns to detect a value
match, however, this requires that both the source text and the pattern we are searching start and end with a
return to catch the value at the beginning or end as well as the middle. So, one may be tempted to approach
the problem like this:
Alternatively, by combining several functions, this formula will safely detect only a full value match
without the need to worry about leading or trailing carriage returns:
Position
The Position function finds the starting character position of a specified occurrence of some text in the
provided text.
304
Chapter 13 ■ Text Functions
Proper
The Proper function transforms the text provided into a “proper” case, with only the first letter of each word
capitalized.
Quote
The Quote function encloses a piece of text in quotation marks.
Here is an example of building a string with some quoted text in the middle:
305
Chapter 13 ■ Text Functions
Replace
The Replace function replaces a specified number of characters at a certain position within a piece of text
with some replacement text.
Right
The Right function extracts a specified number of characters from the provided text starting from the last
character on the right.
RightValues
The RightValues function extracts a specified number of values from a list of values starting from the last
value.
306
Chapter 13 ■ Text Functions
Here are some examples of extracting values from the right (bottom) of a list:
RightWords
The RightsWords function extracts a specified number of words from the text provided, starting from the last
word on the right.
RightWords ( "Hello World. How are you?" ; 3 ) // result = "How are you"
RomanHankaku
The RomanHankaku function converts Zenkaku alphanumeric and symbols in text to Hankaku alphanumeric
symbols. For more information on Japanese functions, see FileMaker’s documentation.
RomanZenkaku
The RomanZenkaku function converts Hankaku alphanumeric and symbols in text to Zenkaku alphanumeric
and symbols. For more information on Japanese functions, see FileMaker’s documentation.
SerialIncrement
The SerialIncrement function detects the first numeric value from the right within a text string and
increments it by a specified number.
307
Chapter 13 ■ Text Functions
SortValues
The SortValues function will rearrange the order of carriage return-delimited values.
Format To sort values as text using the file’s default locale, only a single parameter is required:
SortValues ( values )
Optional parameters allow specification of data type and locale:
SortValues ( values ; datatype ; locale )
Parameters values = a list of carriage return-delimited text values to be sorted.
datatype = (optional) a number indicating the data type of the values. A positive number
results in an ascending sort, a negative value results in a descending sort.
locale = (optional) a text value indicating the locale that should control the sort.
Options for The options for the datatype parameter are:
Datatype 1 — sort as text (default when no datatype is specified)
2 — sort as numeric
3 — sort as date
4 — sort as time
5 — sort as timestamp
Options for The options for the locale parameter are:
Locale Arabic, Bengali, Bulgarian, Catalan, Catalog, Chinese, Chinese_Stroke, Croatian, Czech,
Danish, Dutch, English, Estonian, Finnish, Finnish_Custom, French, German, German_
Dictionary, Greek, Greek_Mixed, Gujarati, Hebrew, Hindi, Hugarian, Icelandic, Italian,
Japanese, Kannada, Korean, Latvian, Lithuanian, Malayalam, Marathi, Norwegian,
Panjabi, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian,
Spanish, Spanish_Traditional, Swedish, Swedish_Custom, Tamil, Telugu, Thai, Turkish,
Ukrainian, Unicode_Raw, Unicode_Standard and Vietnamese.
These only need to be specified when the language of or sorting methodology for the
values differs from that of the operating system upon which the database file was created.
Result The carriage return-delimited list of values reordered based on the parameters specified.
This example sorts text values, using the file’s default locale:
This example shows numbers sorting as text values when no datatype is specified:
SortValues ( "100¶10¶200¶20" )
// result =
10
100
20
200
308
Chapter 13 ■ Text Functions
This example shows numbers sorting as numeric values when a datatype is specified:
SortValues ( "100¶10¶200¶20" ; 2 )
// result =
10
20
100
200
To change the sort order from ascending to descending results, the datatype should be a negative value:
SortValues ( "100¶10¶200¶20" ; -2 )
// result =
200
100
20
10
Substitute
The Substitute function replaces one or more text strings anywhere it appears within a piece of text with a
different string.
Format When substituting a single search-replace pair, the function should be called with three
parameters:
Substitute ( text ; searchString ; replacementString )
Optionally, the function accepts multiple search-replace pairs, in any quantity, each
contained within square brackets and separated by a semi-colon:
Substitute ( text ;
[ searchString1 ; replacementString1 ] ;
[ searchString2 ; replacementString2 ] ;
[ searchString3 ; replacementString3 ]
)
Parameters text = a text value representing the text to be manipulated.
searchString = a text value representing the text to be located and replaced.
replacementString = a text value representing the text to be used to replace the
searchString.
Result The text provided with the specified replacements tasks performed.
309
Chapter 13 ■ Text Functions
In this example, the text in the “Name” field will be cleared of carriage returns and tabs:
This example shows a method of clearing extra space throughout a piece of text. It contains three
substitutions: quadruple space, tripled space, and double space, each replaced with a single space in
succession to ensure that most extra spaces is removed:
Substitute ( Table::Text Field ; [ " " ; " " ] ; [ " " ; " " ] ; [ " " ; " " ] )
Trim
The Trim function removes all leading and trailing spaces from a piece of text. This is useful to correct data entry
errors or when importing from an external data source that contains a fixed number of characters per field.
TrimAll
The TrimAll function manages spaces in a text string based on various criteria. Many of its options are
useful only for non-Roman languages like Japanese and are not specified here. For more information on
Japanese functions, see FileMaker’s documentation.
This example will remove all spaces between Roman characters while always leaving one space
between Roman words:
310
Chapter 13 ■ Text Functions
UniqueValues
The UniqueValues function returns a carriage return-delimited list of values with duplicates removed.
Format To manipulate values as text using the file’s default locale, only a single parameter is required:
UniqueValues ( values )
Optional parameters allow specification of data type and/or locale:
UniqueValues ( values ; datatype ; locale )
Parameters values = a text value that provides a list of carriage return-delimited values to be
processed.
datatype = (optional) a number indicating the data type of the values.
locale = (optional) a text expression indicating the locale that should control the sort.
Result The original carriage return-delimited list of values without duplicates.
UniqueValues ( "15¶125¶10¶125¶10.0" ; 2 )
// result =
15
125
10
■■Note See SortValues for a list of available values for the datatype and locale parameters.
Upper
The Upper function transforms the text provided into uppercase.
ValueCount
The ValueCount function counts the number of values in a list of values.
WordCount
The WordCount function counts the number of words in a piece of text.
Summary
In this chapter, we explored all the built-in functions for manipulating text strings.
312
CHAPTER 14
JSON functions were introduced in FileMaker 16 as a subset of Text Functions. These are used to create and
manipulate JSON objects that contain information stored in a structured text format.
Introducing JSON
JavaScript Object Notation (JSON) provides a lightweight data-interchange format that is both human
readable and easy for computers to manipulate. This popular data format is widely used on websites that
use Representational State Transfer (REST) web services. These functions improve the techniques used
within FileMaker when manipulating data provided by external resources. However, they can also be
enormously useful internally as a data exchange format between scripts and other functions.
For more technical information on JSON, visit: http://www.json.org.
{ "<Key>":<Value> }
{ "<Key1>":<Value1>,"<Key2>":<Value2> }
They key portion, sometimes called a member, is always a text string that names the associated value,
acting kind of like a field name. The value portion contains an actual stored value that can be one of the
following data types:
• JSONString — a text string.
• JSONNumber — a numeric value.
• JSONBoolean — a value that is either true or false.
The object can be typed into a more readable multi-line format, as shown here:
{
"id":5103,
"First":"John",
"Last":"Smith",
"Title":"Chief Technology Officer”
}
This example shows a JSON object containing two elements, Product1 and Product2, each containing a
nested JSON object.
{
"Product1":
{
"id":1000,
"name":"Widget 1",
"price":39.99,
"aisles":[3,8]
},
"Product2":
{
"id":1001,
"name":"Widget 2",
"price":59.99,
"aisles":[2,4]
}
}
This example shows a JSON object containing an array at the top level. Notice that the curly brackets are
only used within the array if the value at a given position is a JSON Object.
[
15,
"Hello World",
{"First":"John","Last":"Smith"}
]
314
Chapter 14 ■ Text Functions (JSON)
■■Tip When writing JSON objects by hand, you can validate them using the tool at: http://www.jsonlint.com.
{
"id":5103,
"First":"John",
"Last":"Smith",
"Title":"Chief Technology Officer”
}
[
15,
"Hello World",
{"First":"John","Last":"Smith"}
]
When referring to a value in an array that is contained within another element rather than at the root level,
you will need to either specify the path or extract the element’s value first and then use the index position.
key1.key2.key3
315
Chapter 14 ■ Text Functions (JSON)
An array, at any level, must denote a numeric index value instead of a named key. In this pattern, the
second level would be an array containing several JSON objects and the path indicates the second of these is
desired:
key1.[2].key3
Using this JSON object, let’s work through some examples of using paths to refer to nested elements:
{
"Product1":
{
"id":1000,
"name":"Widget 1",
"price":39.99,
"aisles":[3,8]
},
"Product2":
{
"id":1001,
"name":"Widget 2",
"price":59.99,
"aisles":[2,4]
}
}
If the keyOrIndexOrPath parameter is “Product2” it will return the entire nested object stored under
that key, as shown here:
Product2 =
{
"id":1001,
"name":"Widget 2",
"price":59.99,
"aisles":[2,4]
}
However, if the keyOrIndexOrPath parameter contains a path “Product2.name” it will only return the
specified element from that product’s object, as shown here:
Product2.name = Widget 2
To access a specific store aisle from the array of values stored in that element, the path would include
the index to the desired array value. For example:
Product2.aisles.[2] = 4
316
Chapter 14 ■ Text Functions (JSON)
JSONDeleteElement
The JSONDeleteElement function deletes a specified element from a JSON object.
This example assumes a field named Data that contains the following JSON object:
An element can be deleted from the object by element name, as shown here:
JSONFormatElements
The JSONFormatElements function inserts extra space into a JSON object to render it in a more readable
format.
317
Chapter 14 ■ Text Functions (JSON)
JSONGetElement
The JSONGetElement function extracts the value for a specific element from a JSON object.
JSONListKeys
The JSONListKeys function extracts a list of the keys of the specified element of a JSON object.
318
Chapter 14 ■ Text Functions (JSON)
JSONListValues
The JSONListValues function extracts a list of the keys of the specified element of a JSON object.
JSONSetElement
The JSONSetElement function adds or modifies the value for a specific element from a JSON object.
319
Chapter 14 ■ Text Functions (JSON)
JSONSetElement ( "";
[ "id" ; 1000 ; JSONNumber ] ;
[ "first" ; "John" ; JSONString ] ;
[ "last" ; "Smith" ; JSONString ] ;
[ "title" ; "Chief Technology Officer" ; JSONString ]
)
// result = {"first":"John","id":1000,"last":"Smith","title":"Chief Technology Officer"}
Summary
In this chapter, we introduced JSON objects and explored all the built-in functions for creating, parsing, and
manipulating them.
320
CHAPTER 15
Text formatting functions are used to modify the font, style, size, and color of text strings, giving developers
control over how text appears in fields on layouts and how it is stored in fields.
These functions are used to apply formatting to the text contained within a field. When a field object is
placed on a layout, formatting can be applied that controls how field content appears for every record when
displayed on a layout. This is completely independent of the actual data stored in the field. When displayed,
layout format settings are superimposed on the field’s text content unless that content has format settings
applied within the field. In that case, the field settings override the layout settings for the portion of text that
has format applied.
All of these functions only affect the formatting of text within the field and not the actual text content.
Some actions performed with formatted text may result in it being converted into plain, unformatted
text. For example, formatting is not retained when text is added to the body of an email using the Send Email
script step.
RGB
The RGB function is used to generate an integer that represents a specific color by combining red, green, and
blue values.
TextColor
The TextColor function applies a specified color to a text string.
322
Chapter 15 ■ Text Formatting Functions
TextColorRemove
The TextColorRemove function removes all font colors or one specific color from a text string depending on
the instructions it receives.
Format To remove all color settings from the entire text, only a single parameter is required:
TextColorRemove ( text )
To remove one color used anywhere in the text, add a second optional parameter that
specifies that color:
TextColorRemove ( text ; RGB )
Parameters text = a text value that contains text formatted in one or more colors.
RGB = (optional) an integer from 0 to 16777215 indicating the desired color for the text
provided. Can be generated by a nested call to the RGB function.
Result The text provided with all or the specified color settings removed.
This example pulls the text out of a field named “Notes” in a Contacts table and removes all color
settings:
TextColorRemove ( Contact::Notes )
The following example uses several functions to apply different colors to some sample text and then
uses TextColorRemove to remove only the green color. If the resulting text is placed into a field, the other
colors would remain while the green text returns to black or whatever layout color setting is applied to the
field object.
Let ( [
textRed = TextColor ( "Hello World Red. " ; RGB ( 255 ; 0 ; 0 ) ) ;
textGreen = TextColor ( "Hello World Blue. " ; RGB ( 0 ; 255 ; 0 ) ) ;
textBlue = TextColor ( "Hello World Green. " ; RGB ( 0 ; 0 ; 255 ) ) ;
textMulti = textRed & textGreen & textBlue
] ;
TextColorRemove (textMulti ; RGB ( 0 ; 255 ; 0 ) )
)
TextFont
The TextFont function changes the font of a text string.
323
Chapter 15 ■ Text Formatting Functions
TextFontRemove
The TextFontRemove function removes all fonts or one specific font from a text string.
Format To remove all font settings from the entire text, only a single parameter is required:
TextFontRemove ( text )
To remove one font used anywhere in the text, add a second optional parameter that
specifies that font name:
TextFontRemove ( text ; fontToRemove )
Parameters text = a text value from which specific font styling should be removed.
fontToRemove = a text value containing the name of the desired font.
Result The text provided with either all or the specified font settings removed.
This example will remove all font settings from any text within a Notes field in a Contacts table:
TextFontRemove ( Contact::Notes )
This example will remove any application of Courier New from anywhere within the text in the field:
TextFormatRemove
The TextFormatRemove function removes all text formatting from a text string including fonts, styles, font
sizes, and font colors.
These examples show the use of the function to remove all formatting from a text string and from text
extracted from a field:
324
Chapter 15 ■ Text Formatting Functions
TextSize
The TextSize function changes the font size of a text string.
These examples show the application of a font size to a text string and to text extracted from a field:
TextSizeRemove
The TextSizeRemove function removes all font size settings or one specific size from a text string.
Format To remove all sizes from the entire text, only a single parameter is required:
TextSizeRemove ( text )
To remove one size used anywhere in the text, add a second optional parameter that
specifies that one size:
TextSizeRemove ( text ; sizeToRemove )
Parameters text = a text value from which text size formatting should be removed.
sizeToRemove = a font size expressed as an integer.
Result The text provided with all or the specified font sizes removed.
This example will remove all font sizes from any text within a “Notes” field in a “Contacts” table:
TextSizeRemove ( Contact::Notes )
This example will remove any application of 18 pt. font size from anywhere within the text:
TextFontRemove ( Contact::Notes ; 18 )
325
Chapter 15 ■ Text Formatting Functions
TextStyleAdd
The TextStyleAdd function changes the font style of a text string.
These examples show the application of one or more styles to a text string or to text extracted from a field:
TextStyleRemove
The TextStyleRemove function removes all font style settings or one or more specific styles from a text string
depending on the instructions it receives.
Format To remove all styles from the entire text, only a single parameter is required:
TextStyleRemove ( text )
To remove one or more specific styles used anywhere in the text, add a second
optional parameter that specifies which styles:
TextSizeRemove ( text ; styles )
Parameters text = a text value from which text styles should be removed.
styles = one or more style names delimited with a plus symbol (+).
Result The text provided with all or the specified font style(s) removed.
This example will remove all font styles from the text extracted from a Notes field in a Contacts table:
TextStyleRemove ( Contact::Notes )
This example will remove any application of specific styles from anywhere within text extracted
from a field:
Summary
In this chapter, we explored the built-in functions for formatting text.
326
CHAPTER 16
Number Functions
Abs
The Abs function calculates the absolute value of a number, which is a non-negative value representing its
distance from zero.
These examples show the function operating on a positive number, negative number, math expression,
a text string containing a number, and a number extracted from a field:
Ceiling
The Ceiling function rounds a number up to the next integer.
Here are some examples of the function operating on a positive and negative number:
Combination
The Combination function calculates the number of combinations possible based on a specific set size and
number of choices, which can be useful in statistics and other mathematics.
328
Chapter 16 ■ Number Functions
Given a set size of three values (a, b, c) and making choices of two values, the number of possible
unique combinations is three; ab, ac, bc. No matter the set size or number of choices, the function will
calculate the possible combinations, as shown in these examples:
This example demonstrates an erroneous attempt to calculate the impossible combinations of six
values with a set of only four values:
Div
The Div function calculates the next lowest integer from the result of a number being divided by a divisor.
Exp
The Exp function calculates the mathematical constant e (approximately equal to 2.7182818) raised to the
power of a specified number.
329
Chapter 16 ■ Number Functions
Factorial
The Factorial function calculates a non-negative integer (n!), which is the product of multiplying all
positive integers less than or equal to a specified number (n), stopping at 1, or at an optional number of
factors.
Format When not specifying a limit to the number of factors, a single parameter is required:
Factorial ( number )
To limit to the number of factors, a second, optional parameter is added:
Factorial ( number ; numberOfFactors )
Parameters number = a positive integer which will be used as n.
numberOfFactors = a positive integer that indicates how many factors should be
included.
Result A number representing the factorial of the number provided.
Floor
The Floor function rounds a number down to the next integer.
Int
The Int function returns the integer part of a number without rounding by dropping any digits to the right of
the decimal.
330
Chapter 16 ■ Number Functions
Lg
The Lg function calculates the base-2 logarithm of a number, which is the power to which the number must
be raised to obtain the value desired.
Format Lg ( number )
Parameters number = a positive number.
Result A number.
Lg ( 4 ) // result = 2
Lg ( -2 ) // result = ? (Error)
Ln
The Ln function calculates the base-e (natural) logarithm of a number, which is the power to which the
mathematical constant e (2.71828182) would have to be raised to equal the number specified.
Format Ln ( number )
Parameters number = any number.
Result A number.
Log
The Log function calculates the base-10 (common) logarithm of a number.
331
Chapter 16 ■ Number Functions
Mod
The Mod function calculates the remainder from the result of a number being divided by a divisor. This is
useful when converting units of measure, such as converting seconds to minutes, minutes to hours, or days
to years.
This example shows the function used with the Int function to convert 310 minutes into a text string
that expresses that as hours and minutes:
Int ( 310 / 60 ) & " hours, " & Mod ( 310 ; 60 ) & " minutes"
// result = 5 hours, 10 minutes
Random
The Random function calculates a pseudo-random number between 0 and .99999999999999999999.
Format Random
Parameters Not applicable
Result A random number.
These examples show the function providing a different value each time it is called:
These examples show how to use the function to generate a random integer between 0 and 10:
332
Chapter 16 ■ Number Functions
Round
The Round function rounds a number to specified number of decimal places.
SetPrecision
The SetPrecision function evaluates a math expression with a specified precision between 16 and 400.
Sign
The Sign function determines if a given number is negative or positive.
333
Chapter 16 ■ Number Functions
Sqrt
The Sqrt function calculates the square root of a number.
Truncate
The Truncate function shortens a number to a specified number of decimal places without rounding.
Summary
In this chapter, we explored all the built-in functions for manipulating numeric values.
334
CHAPTER 17
These three categories provide functions that manipulate date and time values.
Date
The Date function creates a date object from separate numeric month, day, and year values.
This basic example constructs a date object from three numeric values:
This example demonstrates that any of the parameters can be expressions that will be evaluated prior to
the construction of the date:
The function will automatically wrap to a new month, day or year if the month or day provided falls out
of range. For example, a month value of 13 will cause the function to automatically return a date for January
of the following year:
Day
The Day function extracts the day number of the month for a given date.
DayName
The DayName function calculates the name of the weekday for a given date.
336
Chapter 17 ■ Date, Time, and Timestamp Functions
DayNameJ
The DayNameJ function performs the same function as DayName but returns text in Japanese. For more
information on Japanese functions, see FileMaker’s documentation.
DayOfWeek
The DayOfWeek function calculates a number representing the day of the week for a given date.
DayOf Year
The DayOfYear function calculates a number representing the day of the year for a given date.
Month
The Month function calculates the number of the month for a given date.
337
Chapter 17 ■ Date, Time, and Timestamp Functions
MonthName
The MonthName function calculates the name of the month for a given date.
MonthNameJ
The MonthNameJ function performs the same function as MonthName but returns text in Japanese. For more
information on Japanese functions, see FileMaker’s documentation.
WeekOfYear
The WeekOfYear function calculates a number representing the week of the year for a given date.
338
Chapter 17 ■ Date, Time, and Timestamp Functions
WeekOfYearFiscal
The WeekOfYearFiscal function calculates a number representing the week of a year for a given date based
on a specified starting date for a workweek. This is sometimes useful in accounting to calculate if a year has
an extra pay period because a week is split across the calendar year boundary.
These examples show how January 2, 2009, which falls on a Friday, can be either the first week of 2009
or the fifty-third week of 2008 depending on the day considered to be the start of the week:
Year
The Year function returns the year for a given date.
YearName
The YearName function calculates the Japanese year name of a given date. For more information on Japanese
functions, see FileMaker’s documentation.
339
Chapter 17 ■ Date, Time, and Timestamp Functions
Hour
The Hour function extracts the number of hours of a given time.
Minute
The Minute function extracts the number of minutes from a given time.
340
Chapter 17 ■ Date, Time, and Timestamp Functions
Seconds
The Seconds function extracts the number of seconds from a given time.
Time
The Time function creates a time object from separate numeric hours, minutes, and seconds values.
Timestamp
The Timestamp function creates a timestamp based on a given date and time.
341
Chapter 17 ■ Date, Time, and Timestamp Functions
These examples show that timestamps will automatically add the appropriate AM/PM suffix to the
time portion:
If the hours are out of range, as in military time, the function will automatically convert to civilian time,
also with the appropriate AM/PM suffix:
Summary
In this chapter, we explored all the built-in functions for manipulating date, time, and timestamp values.
342
CHAPTER 18
Container Functions
Container functions are used to analyze, manipulate, and report about data in container fields.
Base64Decode
The Base64Decode function converts Base64 encoded text into its original content: either text or container
data. Since Base64 format does not preserve the file name or extension, these can be included as an
optional parameter.
Base64 is a group of encoding schemes for converting binary content to ASCII strings. Generally, it
is used to encode graphics, files, and applications for transmission using methods designed to deal with
textual data. In FileMaker, these types of data are stored in container fields.
Format Without specifying a file name and extension, generic values will be automatically
created. In this case, only the text being decoded need be included:
Base64Decode ( text )
To specify a file name with an extension for the file being created, add a second
parameter:
Base64Decode ( text ; fileNameWithExtension)
Parameters text = a text value encoded as Base64 that will be decoded.
fileNameWithExtension = (optional) a text value that contains a file name and
extension for the file being created from the Base64 text.
Result A text string suitable for placement in a text or container field.
More Info For more information about Base64 visit:
https://www.base64decode.org.
This example shows the encoded contents of a field named EncodedData being converted into an image
with a name of sample.jpg:
Base64Encode
The Base64Encode function converts text or container data into Base64 formatted text.
Base64Encode ( Image::PreviewImage )
// result = the image as a string of text characters in Base64 format
Base64EncodeRFC
The Base64EncodeRFC function converts text or container data into the specified Base64 formatted text.
A Request for Comment (RFC) is a series of documents that emerged from the research efforts that
created the ARPANET and later the Internet. When the Internet Engineering Task Force (IETF) was formed in
the mid-1980s, RFCs were the primary vehicle for publishing IETF standards, many pertaining to the Internet
protocols.
344
Chapter 18 ■ Container Functions
This example shows the function encoding some text using the 3548 RFC:
CryptAuthCode
The CryptAuthCode function returns a binary keyed-hash message authentication code (HMAC) of text or
container data using a specified cryptographic hash algorithm.
When this example is used as a calculation field resulting in container data or when the result is placed
into a container field by script, the result will be an encrypted text file named hmac.data:
345
Chapter 18 ■ Container Functions
CryptEncrypt
The CryptEncrypt function encrypts text or container data into an encrypted file.
To convert the key parameter into a cryptographic key, the function uses the Password-Based Key
Derivation Function 2 (PBKDF2) algorithm, which is part of RSA Laboratories’ Public-Key Cryptography
Standards (PKCS) series that was published as RFC 2898 by the Internet Engineering Task Force.
The cryptographic key is then used to encrypt the data using the Advanced Encryption Standard Galois/
Counter Mode (AES-GCM) 128-bit algorithm. The resulting encrypted file includes an encrypted 256-bit
Secure Hash Algorithm (SHA-256) digest of the data that is used to validate the data during encryption.
■■Caution The Crypt functions are not supported in runtime solutions (Chapter 41, “Developer Utilities”) and
will return an error.
When this example is used as a calculation field resulting in container data or when the result is placed
into a container field by script, the result will be an encrypted text file named encrypted.data:
CryptEncryptBase64
The CryptEncryptBase64 function encrypts text or container data into Base64 text.
Example
346
Chapter 18 ■ Container Functions
CryptDecrypt
The CryptDecrypt function converts an encrypted data file from a container back into its original content.
This example assumes a field containing the encrypted.data file generated from the CryptEncrypt
example:
CryptDecryptBase64
The CryptDecryptBase64 function converts text encrypted in Base64 format back into its original content.
This example assumes that the Example Calculation field contains the encrypted text that resulted
from the CryptEncryptBase64 example:
CryptDigest
The CryptDigest function returns a binary hash value of text or container data using a specified
cryptographic hash algorithm.
347
Chapter 18 ■ Container Functions
When this example is used as a calculation field resulting in container data or when the result is placed
into a container field by script, the result will be an encrypted text file named digest.data:
GetContainerAttribute
The GetContainerAttribute function returns an attribute from the file metadata of a container field.
AttributeName Options
The attributeName parameter can contain the name of an individual attribute or a group of attributes.
■■Caution When attributes are retrieved in groups they always include a label with the value, while
individual attributes only return the value. Some attributes will return either a number that indicates a value
or a number with the text explanation of the value in parentheses. For more details on the values returned,
experiment with groups or consult FileMaker’s help documentation.
Groups of Attributes
The following groups of attributes can be retrieved:
• all = returns every attribute applicable to the file in the container
• general = returns every attribute applicable to all files types
• audio = returns every attribute applicable to audio files
• image = returns every attribute applicable to images
• photo = returns every attribute applicable to photographs
• barcode = returns every attribute applicable to barcodes
• signature = returns every attribute applicable to signatures
348
Chapter 18 ■ Container Functions
General Attributes
The following attributes are in the general group and are applicable to every file type:
• filename = the name of the file
• MD5 = a cryptographic has function result for the file, which can be used to identify
duplicates with different file names
• storageType = the method of storage for the file; Embedded, External (Secure),
External (Open), File Reference, Text
• fileSize = the size of the file in bytes
• internalSize = the amount of space used inside the database by the container field
(in bytes)
• externalSize = the amount of space that is used outside the database by the
container field (in bytes)
• externalFiles = a list of external files in the container field
Image Attributes
The following attributes are in the image group and are applicable to images:
• width
• height
• dpiWidth
• dpiHeight
• transparency
Photo Attributes
The following attributes are in the photo group and are applicable to jpeg and tiff files only:
• orientation = the orientation of the photo
• created = the earliest timestamp available for the photo
• modified = the latest timestamp available for the photo; an empty string indicates
the photo has not been modified
• latitude = the latitude of the location where the photo was taken
• longitude = the longitude of the location where the photo was taken
• make = the manufacture of the camera used to take the photo
• model = the model of the camera used to take the photo
349
Chapter 18 ■ Container Functions
Audio Attributes
The following attributes are in the audio group and are applicable to mp3 and m4a files only:
• title
• artist
• year
• track
• genre
• composer
• cover Art
• duration
• bitRate
Barcode Attributes
The following attributes are in the barcode group and are applicable to barcode files only:
• barcodeText
• barcodeType
Signature Attributes
The following attributes are in the signature group and are applicable to signatures only:
• signed = the timestamp when the signature was captured
Examples
These examples retrieve an individual attribute from the general group:
350
Chapter 18 ■ Container Functions
[Audio]
Title: Since I've Been Loving You
Artist: Led Zeppelin
Album: Led Zeppelin III
Year: 1970
Track: 4/10
Genre: Rock
Composer:
Cover Art:
Duration: 0:07:23
Bit Rate: 128 kbps
GetHeight
The GetHeight function returns the height in pixels of an image in a container.
351
Chapter 18 ■ Container Functions
This example shows the function returning the height of an image stored in a container field:
GetThumbnail
The GetThumbnail function creates data representing a thumbnail image of the content in a container field
to a specified height and width.
This example shows the function scaling an image from a container field. Notice that the fitToWidth
measurement is ignored to preserve the proportions of the image, favoring the fitToHeight specification.
This example shows the function scaling an image to half the height and width, which are both
dynamically calculated using the GetWidth and GetHeight functions:
GetThumbnail (
Example::ContainerField ;
GetWidth (Example::ContainerField ) / 2 ;
GetHeight (Example::ContainerField ) / 2
)
// result = a thumbnail of the image scaled to 50%
GetWidth
The GetWidth function returns the width in pixels of an image in a container.
352
Chapter 18 ■ Container Functions
This example shows the function calculating the width of an image stored in a container field:
HexEncode
The HexEncode function will encode text or container data into hexadecimal (base-16) format.
This example shows the function converting a text string into hexadecimal format:
HexDecode
The HexDecode function will decode text from hexadecimal (base-16) format back into regular text or
container data.
Format When converting text encoded as hexadecimal, only the text being decoded need be
included:
Base64Decode ( text )
To specify a file name with an extension when decoding a file for insertion into a
container being, add a second parameter:
Base64Decode ( text ; fileNameWithExtension)
Parameters data = a text value that was previously encoded into hexadecimal format.
fileNameWithExtension = (optional) a text value that contains a file name and extension
for the file being decoded.
Result Text or container data.
This example shows the function converting a hexadecimal string back into its original decoded format:
353
Chapter 18 ■ Container Functions
TextEncode
The TextEncode function encodes text, converting it into a text file that can be placed into a container field
and then exported.
When this example is used as a calculation field resulting in container data or when the result is placed
into a container field by script, the result will be a text file named macintosh.txt:
TextDecode
The TextDecode function decodes a text file in a container field, converting it into a plain text that can be
placed into a field.
354
Chapter 18 ■ Container Functions
When a text file containing the phrase “Hello World” is stored in a container field named Example
Container:
VerifyContainer
The VerifyContainer function determines if the data in a container field was changed or deleted outside of
FileMaker.
This example shows the function confirming that the data container field has not been modified
externally.
Summary
In this chapter, we explored all the built-in functions for working with container data.
355
CHAPTER 19
There are three categories of functions that handle the manipulation of multiple values.
Figure 19-1. A set of fields, local and related, with simple values that are used for all the examples in this
section
Average
The Average function calculates the average of all values in one or more fields.
Format A single repeating or related numeric field can be specified with one parameter:
Average ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a semicolon
delimiter:
Average ( field1 ; field2 ; field3 ; etc. )
Parameters field = numeric values.
Result A number representing the average of the values specified, varying based on the combination of
literal values, non-repeating fields, repeating fields, or related fields included in the parameter(s).
Average Examples
The examples in this section assume the data shown in Figure 19-1.
358
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A single repeating local field will return the average based on all the values contained within that field:
Average ( Example::Repeating1 )
// result = 6
A list of repeating local fields used in a non-repeating calculation will return the average based on the
first repetition from each field provided:
A list of repeating local fields used in a repeating calculation returns the average for each repletion of the
result based on the corresponding repetition from each field provided:
Average ( Related::NonRepeating1 )
// result = 32
A list of related, non-repeating fields returns the average based on the values from the fields provided for
the first related record:
A single related, repeating field will return the average based on the values from every repetition from
every record related to the local record performing the calculation:
Average ( Related::Repeating1 )
// result = 37
A list of related, repeating fields used in a non-repeating calculation will return the average based on the
values from the first repetition of those fields from the first record related to the local record performing the
calculation:
359
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of related, repeating fields used in a repeating calculation will return the average based on the
values from the corresponding repletion from each field provided from the first record related to the local
record performing the calculation:
Count
The Count function counts the number of values in one or more fields.
Format A single repeating or related field can be specified with one parameter:
Count ( field )
Multiple fields (repeating or not) or values can be used, with a semicolon delimiter:
Count ( field1 ; field2 ; field3 ; etc. )
Parameters field = any text values.
Result A number: the total count of the values provided, varying based on the combination
of literal values, non-repeating fields, repeating fields, or related fields included in the
parameter(s).
Count Examples
The examples in this section assume the data shown in Figure 19-1.
■■Caution Although all the examples below count lists of numeric values, remember that the Count function
can count any text values. For example, the result of counting "8¶10¶2" and "Mon¶Tues¶Wed" are the same: 3.
A single repeating local field will return the total non-blank value count based on all the values
contained within that field:
Count ( Example::Repeating1 )
// result = 5
360
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of repeating local fields used in a non-repeating calculation will return the total non-blank value
count based on the first repetition from each field provided:
A list of repeating local fields used in a repeating calculation return the total non-blank value count for
each repletion of the result based on the corresponding repetition from each field provided:
Count ( Related::NonRepeating1 )
// result = 3
A list of related, non-repeating fields returns the total non-blank value count based on the values from
the fields provided for the first related record:
A single related, repeating field will return the total non-blank value count based on the values from
every repetition from every record related to the local record performing the calculation:
Count ( Related::Repeating1 )
// result = 15
A list of related, repeating fields used in a non-repeating calculation will return the total non-blank value
count based on the values from the first repetition of those fields from the first record related to the local
record performing the calculation:
A list of related, repeating fields used in a repeating calculation will return the total non-blank value
count based on the values from the corresponding repetition from each field provided from the first record
related to the local record performing the calculation:
List
The List function generates a carriage return-delimited list of values for one or more fields.
Format When listing values from a single repeating field or a single related field, only one parameter
is required:
List ( field )
Optionally, multiple fields can be added with semicolon delimiters:
List ( field1 ; field2 ; field3 ; etc )
Parameters field = a field reference.
Result A carriage return-delimited text-based list of values from the specified field(s), varying
based on the combination of non-repeating, repeating, or related fields included in the
parameter(s).
List Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return a carriage return-delimited list based on all the values contained
within that field:
List ( Example::Repeating1 )
// result = 4¶5¶6¶7¶8
A list of repeating local fields used in a non-repeating calculation will return a carriage return-delimited
list based on the first repetition from each field provided:
A list of repeating local fields used in a repeating calculation return a carriage return-delimited list for
each repetition of the result based on the corresponding repetition from each field provided:
362
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
List ( Related::NonRepeating1 )
// result = 19¶32¶45
A list of related, non-repeating fields return a carriage return-delimited list based on the values from the
fields provided for the first related record:
A single related, repeating field will return a carriage return-delimited list based on the values from every
repetition from every record related to the local record performing the calculation:
List ( Related::Repeating1 )
// result = 22¶23¶24¶25¶26¶35¶36¶37¶38¶39¶48¶49¶50¶51¶52
A list of related, repeating fields used in a non-repeating calculation will return a carriage return-delimited
list based on the values from the first repetition of those fields from the first record related to the local record
performing the calculation:
A list of related, repeating fields used in a repeating calculation will return a carriage return-delimited list
based on the values from the corresponding repetition from each field provided from the first record related
to the local record performing the calculation:
Max
The Max function extracts the highest value from a list of values.
Format A single repeating or related numeric field can be specified with one parameter:
Max ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a semicolon
delimiter:
Max ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the highest value from the values provided, varying based on the
combination of separate numeric values, non-repeating fields, repeating fields, or related
fields included in the parameter(s).
363
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
Max Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the highest value based on all the values contained within that field:
Max ( Example::Repeating1 )
// result = 8
A list of repeating local fields used in a non-repeating calculation will return the highest value based on
the first repetition from each field provided:
A list of repeating local fields used in a repeating calculation returns the highest value for each repetition
of the result based on the corresponding repetition from each field provided:
Max ( Related::NonRepeating1 )
// result = 45
A list of related, non-repeating fields return the highest value based on the values from the fields
provided for the first related record:
A single related, repeating field will return the highest value based on the values from every repetition
from every record related to the local record performing the calculation:
Max ( Related::Repeating1 )
// result = 52
364
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of related, repeating fields used in a non-repeating calculation will return the highest value
based on the values from the first repetition of those fields from the first record related to the local record
performing the calculation:
A list of related, repeating fields used in a repeating calculation will return the highest value based on the
values from the corresponding repetition from each field provided from the first record related to the local
record performing the calculation:
Min
The Max function extracts the lowest value from a list of values.
Format A single repeating or related numeric field can be specified with one parameter:
Min ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a semicolon
delimiter:
Min ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the lowest value from the values provided, varying based on the
combination of separate numeric values, non-repeating fields, repeating fields, or related
fields included in the parameter(s).
Min Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the lowest value based on all the values contained within that field:
Min ( Example::Repeating1 )
// result = 4
365
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of repeating local fields used in a non-repeating calculation will return the lowest value based on
the first repetition from each field provided:
A list of repeating local fields used in a repeating calculation return the lowest value for each repetition
of the result based on the corresponding repetition from each field provided:
Min ( Related::NonRepeating1 )
// result = 19
A list of related, non-repeating fields returns the lowest value based on the values from the fields
provided for the first related record:
A single related, repeating field will return the lowest value based on the values from every repetition
from every record related to the local record performing the calculation:
Min ( Related::Repeating1 )
// result = 22
A list of related, repeating fields used in a non-repeating calculation will return the lowest value based on
the values from the first repetition of those fields from the first record related to the local record performing
the calculation:
A list of related, repeating fields used in a repeating calculation will return the lowest value based on the
values from the corresponding repetition from each field provided from the first record related to the local
record performing the calculation:
StDev
The StDev function calculates the standard deviation of a list of values. Standard deviation is a measure of
how spread out a set of numbers are from their mean, which is calculated by taking the square root of the
average of the squared deviations of the values from their average value.
Format A single repeating or related numeric field can be specified with one parameter:
StDev ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a
semicolon delimiter:
StDev ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the standard deviation from the values provided, varying based
on the combination of separate numeric values, non-repeating fields, repeating fields, or
related fields included in the parameter(s).
More Info For background information on standard deviation visit:
https://en.wikipedia.org/wiki/Standard_deviation.
StDev Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the standard deviation based on all the values contained within
that field:
StDev ( Example::Repeating1 )
// result = 1.5811388300841897
A list of repeating local fields used in a non-repeating calculation will return the standard deviation
based on the first repetition from each field provided:
367
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of repeating local fields used in a repeating calculation return the standard deviation for each
repetition of the result based on the corresponding repetition from each field provided:
StDev ( Related::NonRepeating1 )
// result = 13
A list of related, non-repeating fields returns the standard deviation based on the values from the fields
provided for the first related record:
A single related, repeating field will return the standard deviation based on the values from every
repetition from every record related to the local record performing the calculation:
StDev ( Related::Repeating1 )
// result = 11.0840941378690418
A list of related, repeating fields used in a non-repeating calculation will return the standard deviation
based on the values from the first repetition of those fields from the first record related to the local record
performing the calculation:
A list of related, repeating fields used in a repeating calculation will return the standard deviation based
on the values from the corresponding repetition from each field provided from the first record related to the
local record performing the calculation:
368
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
StDevP
The StDevP function calculates the standard deviation of a population represented by a list of values.
Format A single repeating or related numeric field can be specified with one parameter:
StDevP ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a
semicolon delimiter:
StDevP ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the standard deviation of a population from the values provided,
varying based on the combination of separate numeric values, non-repeating fields,
repeating fields, or related fields included in the parameter(s).
StDevP Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the standard deviation of a population based on all the values
contained within that field:
StDevP ( Example::Repeating1 )
// result = 1.414213562373095
A list of repeating local fields used in a non-repeating calculation will return the standard deviation of a
population based on the first repetition from each field provided:
A list of repeating local fields used in a repeating calculation return the standard deviation of a
population for each repetition of the result based on the corresponding repetition from each field provided:
369
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
StDevP ( Related::NonRepeating1 )
// result = 10.6144555520604384
A list of related, non-repeating fields return the standard deviation of a population based on the values
from the fields provided for the first related record:
A single related, repeating field will return the standard deviation of a population based on the values
from every repetition from every record related to the local record performing the calculation:
StDevP ( Related::Repeating1 )
// result = 10.7082522694726737
A list of related, repeating fields used in a non-repeating calculation will return the standard deviation of
a population based on the values from the first repetition of those fields from the first record related to the
local record performing the calculation:
A list of related, repeating fields used in a repeating calculation will return the standard deviation of a
population based on the values from the corresponding repetition from each field provided from the first
record related to the local record performing the calculation:
Sum
The Sum function adds a series of numbers into a total.
Format A single repeating or related numeric field can be specified with one parameter:
Sum ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a semicolon
delimiter:
Sum ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the total of the values provided, varying based on the combination
of separate numeric values, non-repeating fields, repeating fields, or related fields included
in the parameter(s).
370
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
Sum Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the sum total based on all the values contained within that field:
Sum ( Example::Repeating1 )
// result = 30
A list of repeating local fields used in a non-repeating calculation will return the sum total based on the
first repetition from each field provided:
A list of repeating local fields used in a repeating calculation returns the sum total for each repetition of
the result based on the corresponding repetition from each field provided:
Sum ( Related::NonRepeating1 )
// result = 96
A list of related, non-repeating fields returns the sum total based on the values from the fields provided
for the first related record:
A single related, repeating field will return the sum total based on the values from every repetition from
every record related to the local record performing the calculation:
Sum ( Related::Repeating1 )
// result = 555
371
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of related, repeating fields used in a non-repeating calculation will return the sum total based on
the values from the first repetition of those fields from the first record related to the local record performing
the calculation:
A list of related, repeating fields used in a repeating calculation will return the sum total based on the
values from the corresponding repetition from each field provided from the first record related to the local
record performing the calculation:
Variance
The Variance function calculates the variance of a series of numbers. Variance is a measure of how varied a
distribution of numbers is from its mean.
Format A single repeating or related numeric field can be specified with one parameter:
Variance ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a
semicolon delimiter:
Variance ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the variance of the values provided, varying based on the
combination of separate numeric values, non-repeating fields, repeating fields, or related
fields included in the parameter(s).
More Info For more general information about variance, visit:
https://en.wikipedia.org/wiki/Variance.
Variance Examples
The examples in this section assume the data shown in Figure 19-1.
372
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A single repeating local field will return the variance based on all the values contained within that field:
Variance ( Example::Repeating1 )
// result = 2.5
A list of repeating local fields used in a non-repeating calculation will return the variance based on the
first repetition from each field provided:
A list of repeating local fields used in a repeating calculation returns the variance for each repetition of
the result based on the corresponding repetition from each field provided:
Variance ( Related::NonRepeating1 )
// result = 169
A list of related, non-repeating fields returns the variance based on the values from the fields provided
for the first related record:
A single related, repeating field will return the variance based on the values from every repetition from
every record related to the local record performing the calculation:
Variance ( Related::Repeating1 )
// result = 122.8571428571428571
A list of related, repeating fields used in a non-repeating calculation will return the variance based on the
values from the first repetition of those fields from the first record related to the local record performing the
calculation:
373
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of related, repeating fields used in a repeating calculation will return the variance based on the
values from the corresponding repetition from each field provided from the first record related to the local
record performing the calculation:
VarianceP
The VarianceP function calculates the variance of a population distribution of a series of numbers.
Format A single repeating or related numeric field can be specified with one parameter:
VarianceP ( field )
Multiple numeric fields (repeating or not) or numeric values can be used, with a semicolon
delimiter:
VarianceP ( field1 ; field2 ; field3 ; etc )
Parameters field = numeric values.
Result A number representing the variance of a population distribution of the values provided,
varying based on the combination of separate numeric values, non-repeating fields,
repeating fields, or related fields included in the parameter(s).
VarianceP Examples
The examples in this section assume the data shown in Figure 19-1.
A single repeating local field will return the variance of a population based on all the values contained
within that field:
VarianceP ( Example::Repeating1 )
// result = 2
A list of repeating local fields used in a non-repeating calculation will return the variance of a population
based on the first repetition from each field provided:
374
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
A list of repeating local fields used in a repeating calculation returns the variance of a population for
each repetition of the result based on the corresponding repetition from each field provided:
VarianceP ( Related::NonRepeating1 )
// result = 112.6666666666666667
A list of related, non-repeating fields returns the variance of a population based on the values from the
fields provided for the first related record:
A single related, repeating field will return the variance of a population based on the values from every
repetition from every record related to the local record performing the calculation:
VarianceP ( Related::Repeating1 )
// result = 114.6666666666666667
A list of related, repeating fields used in a non-repeating calculation will return the variance of a
population based on the values from the first repetition of those fields from the first record related to the
local record performing the calculation:
A list of related, repeating fields used in a repeating calculation will return the variance of a population
based on the values from the corresponding repetition from each field provided from the first record related
to the local record performing the calculation:
375
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
Summary Functions
Summary functions are used to calculate a summary of values for a field in all records in a found set or to
summarize values for records into different subgroups. FileMaker provides one built-in summary function:
• GetSummary
GetSummary
The GetSummary function returns the value of a summary field for the current found set of records. This
allows a calculation formula to perform a similar function to what a summary field can display on a layout
(Chapter 8, “Summary Fields”).
Assume a table with the fields, records and values, sorted shown in Table 19-1. The Example Summary
field is defined to be a total summary of the Example Value field.
On a layout, the summary field displays the total for all records unless it is placed within a
sub-summary layout part (Chapter 28, “Defining Summary Parts”). Since summary fields only summarize
on layouts and are not accessible to calculations, you must create a new calculation field named Example
Summary Calculation and a formula using the GetSummary function in order to access the summary for
further manipulation.
In this first example, both parameters are pointing to the Example Summary field. The result is the total
for all records in the found set, like what would appear on a layout.
376
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
However, in the following example, the breakField parameter points to the Example City field.
The result will now vary from one record to the next. Because it will be sub-summarizing the result based on
the Example City field, a result of 20 will appear on the first two records and a value of 30 on the last three.
Extend
The Extend function allows a repeating and a non-repeating field to be used together within a repeating
calculation. The non-repeating field is “extended” so that it can be used or compared with each repetition in
a repeating field as if it were a repeating field (Chapter 8, “Repeating”).
This example assumes an Invoice database where a record’s SubTotalCost field contains 100.00. This
single amount must be combined with the cost of five different shipping methods to arrive at five different
grand totals that are offered to a customer. Each shipping cost is stored in one cell of a repeating field named
ShippingCost with values of 5, 28, 15, 40, and 13. The formula and results below are for a GrandTotal
calculation field that has five repetitions. Since the SubTotalCost field is extended, its single value will be
successfully added to all five values in ShippingCost to arrive at five results.
377
Chapter 19 ■ Aggregate, Summary, and Repeating Functions
GetRepetition
The GetRepetition function returns the contents of a single repetition of a repeating field.
These examples show the different results pulled from different repetitions of the same field. It assumes
an Invoice database has a Line Item Qty field with five repetitions containing the following values: 5, 28,
15, 40, and 13:
Last
The Last function returns the last non-blank value from a repeating field.
This example shows the result when an invoice database has a Line Item Qty field with 5 repetitions
containing the following three values: 5, 28, and 15:
Summary
In this chapter, we explored all the built-in functions for performing aggregate, summary, and repeating
calculations.
378
CHAPTER 20
These two categories of functions handle financial and advanced mathematical calculations.
FV
The FV function returns the future value of an investment, based on a fixed interest rate and payment
amount for a specified period of months.
This example shows the total payment on a loan of $1,000 that will be paid back over 10 months with an
interest rate of 2.75%, rounded to two decimal places:
NPV
The NPV function returns the net present value of a series of unequal payments that are made at regular
intervals at a fixed rate of interest.
This example assumes that the repeating field, Payments contains -5000 (the loan amount), 1000,
1200, 500, 500, 3000.
PMT
The PMT function returns the payment required by a loan amount and interest rate for a given term.
A 30-month loan for $10,000 at an interest rate of 5% would require a payment calculated as follows:
PV
The PV function returns the present value, or present discounted value, of a loan, which is an expectation of
the value of income as of the current date.
380
Chapter 20 ■ Financial and Trigonometric Functions
This example shows a calculation of the present value of a loan with 30 payments of $350 each at a 5%
interest rate, rounded to two digits:
Acos
The Acos function returns the arccosine, or inverse cosine, of a number.
381
Chapter 20 ■ Financial and Trigonometric Functions
Asin
The Asin function returns the arcsine, or inverse sine, of a number.
Atan
The Atan function returns the arc tangent, or inverse tangent, of a number.
This example shows the function calculating the arc tangent of .5:
Cos
The Cos function returns the cosine of an angle.
Degrees
The Degrees function converts an angle to degrees.
382
Chapter 20 ■ Financial and Trigonometric Functions
This example shows the function converting an angle of .95 into degrees:
Pi
The Pi function returns the value of the constant Pi.
Format Pi
Parameters Not applicable
Result The constant Pi to 16 decimal places.
Radians
The Radians function converts an angle expressed in degrees into radians.
This example shows the function converting a 90-degree angle into radians:
Sin
The Sin function returns the sine of an angle expressed in radians.
383
Chapter 20 ■ Financial and Trigonometric Functions
Tan
The Tan function returns the tangent of an angle expressed in radians.
Summary
In this chapter, we explored all the built-in functions for performing financial and trigonometric
calculations.
384
CHAPTER 21
Logical Functions
Logical functions are used to test conditions to produce variable results and perform other evaluative functions.
Case
The Case function evaluates one or more expressions, in order, and returns a result corresponding to the
first expression to return a true result. If none of the expressions are true, an optional default result will be
returned. Case is somewhat like an if-then function but can handle multiple statements with less verbiage.
Format With a single test-result pair and no default result, only two parameters are required:
Case ( test1 ; result1 )
Add additional test-result pairs as needed:
Case ( test1 ; result1 ; test2 ; result2 )
A default result can be included, which will be used if none of the other test expressions
produce a result:
Case ( test1 ; result1 ; test2 ; result2 ; defaultResult )
As these statements grow, consider adding carriage returns to reformat them vertically,
putting each pair on its own line and making the statement easier to read:
Case (
test1 ; result1 ;
test2 ; result2 ;
test3 ; result3 ;
test4 ; result4 ;
defaultResult
)
Parameters test = a text or numeric expression that evaluates to a Boolean.
result = a literal result or expression that generates a result that will correspond to the paired test.
defaultResult = (optional) a result that will be used if none of the provided tests are true.
Result A result provided that corresponds to the true test in whatever data type is generated.
This simple example uses the number of days from a field named “Elapsed” to determine how overdue
a payment has become.
Case (
Elapsed > 90 ; "Severe" ;
Elapsed > 60 ; "Delinquent" ;
Elapsed > 30 ; "Past Due" ;
"On Time"
)
The result of the calculation will vary depending on the number in that field.
Choose
The Choose function evaluates a single test condition to generate an integer that is used to select from a list
of one or more provided results. The results are zero-based, so the first result is returned if the test condition
evaluates to a 0, the second result for a 1, and so on.
386
Chapter 21 ■ Logical Functions
Format If there is only one possible result, only two parameters are required:
Choose ( test ; result0 )
Additional results can be added with a semicolon delimiter:
Choose ( test ; result0 ; result1 ; result2 ; etc. )
As these statements grow, consider adding carriage returns to reformat them vertically,
putting each pair of conditions on its own line and making the statement easier to read:
Choose (
test1 ;
result0 ;
result1 ;
result2 ;
result3
)
Parameters test = a number of expression that evaluates to an integer.
result = a literal result or expression.
Result The result located at the position indicated by the integer generated by the test expression.
This simple example uses a value from a field named “Status” to determine how overdue a payment has
become.
The result of the above calculation will vary depending on the number contained in the Status field, as
shown here:
Evaluate
The Evaluate function converts any text-based expression into a calculation and then executes it to generate
a result. Creative use of this function gives developers a powerful ability to create variable functionality in
the form of dynamic calculations that can be built automatically by the database and executed as needed.
387
Chapter 21 ■ Logical Functions
This shows a simple math equation being evaluated. Notice that the formula is a text string and not a
compiled equation.
This example shows a formula pulled from a field named CalcFormula that will execute anytime the
First Name or Last Name fields are modified.
One use of this function is to create dynamic variables with a variable name based on a text value pulled
from a specific record. In this example, an invoice contains a company code, which is used as the name of a
new variable that will store the amount due:
Evaluate (
"Let [ $$" & Invoice::CompanyCode & " = " &
Quote ( Invoice::AmountDue ) & " ] ;
" & Quote ( "" ) & " )"
)
The above example demonstrates just how quickly even a simple use of this function can become
confusing. To avoid this, write a compiled formula as an example of what functions the dynamic one will
perform and then work backwards, converting it into a text string and evaluating that to see if the result is the
formula you started with. Then, wrap it in an Evaluate function and make generic any hard-coded values
it may contain and it will be ready for use. The text expression above is dynamically generating the code
below (with spaces added for clarity), inserting a field value for the variable name and the amount, and then
evaluating it.
Let [
$$WriteTrackMedia = "$15.00"
] ;
""
)
EvaluationError
The EvaluationError function returns an code if an error is generated by an Evaluate function call.
A script can use this function to first test an expression and report errors more intelligently to a user.
This example attempts to evaluate a text-based Get ( Current Date ) function that is missing the
closing parenthesis and will, therefore, generate an error:
388
Chapter 21 ■ Logical Functions
■■Note Error 1207 indicates an error of “Unbalanced Parenthesis.” For a complete list of errors, visit http://
www.filemaker.com/help/14/fmp/en/html/error_codes.html
When the formula in the text string is corrected, the function confirms it by returning zero:
ExecuteSQL
The ExecuteSQL function performs an SQL query statement in a FileMaker database. This function is
discussed in detail in Chapter 26.
GetAsBoolean
The GetAsBoolean function converts an expression into a Boolean based on it evaluating to true or false.
GetAVPlayerAttribute
The GetAVPlayerAttribute function returns one or more attributes for the audio, video, or image file being
played within in a container field on FileMaker Go.
389
Chapter 21 ■ Logical Functions
Requesting all attributes returns a nice, readable list of every attribute in a human-readable format:
GetAVPlayerAttribute ( "all" )
// result =
[AVPlayer Attributes]
However, when requesting a single attribute, it returns a code indicating the result.
FileMaker’s help documentation includes a full list of these codes and their readable translation.
However, another option is to request all attributes and then parse out the information desired using several
other functions, as shown in this example:
Let ( [
values = GetAVPlayerAttribute ( "all" );
attribute = "Playback State" ;
start = Position ( values ; attribute ; 1 ; 1 ) ;
data = Right ( values ; Length ( values ) - start ) ;
data = Substitute ( data ; ": " ; "¶" ) ;
data = GetValue ( data ; 2 )
] ;
data
)
GetField
The GetField function returns the contents of a field based on the name of the field in a text string rather
than a dynamic reference.
390
Chapter 21 ■ Logical Functions
The parameter can be either the name of the field or a text-based reference to the field. Use the latter for
a field from a related table.
■■Caution When using this function, it is advisable to not use hard-coded text for field names since they will
not be updated when field names change. Instead use the GetFieldName function to convert a dynamic field
reference into a text-based field reference and then pass that to the GetField function.
If the parameter is a field reference and that field’s contents are the name of a field, the function will return
the contents of the field named within the field specified. For example, if there is a field named ReferringField
that contains the value People::Full Name, the result of this example will be the same as above:
However, if a field reference points to a field that contains anything other than the name of a field, the
result will be an error.
GetFieldName
The GetFieldName function returns the name of a field reference.
This example shows the function converting a dynamic field reference into a text-based field reference:
■■Caution In most cases, when a field reference is provided to a function, the function is using the reference
to access and manipulate the field value. However, in this case, the function ignores the field value and instead
focuses on the field reference itself, returning the reference as a text string.
391
Chapter 21 ■ Logical Functions
GetLayoutObjectAttribute
The GetLayoutObjectAttribute function will return an attribute of a named layout object from the current
layout.
AttributeName Options
The attributeName parameter can contain any of the following attributes:
• objectType
• hasFocus = returns a Boolean indicating if the object has focus
• containsFocus = returns a Boolean indicating if the object contains the object that
has focus
• isFrontPanel = (tab or slide panel only) returns a Boolean indicating if the object his
in front
• isActive = returns a Boolean indicating if the object is active or not
• isObjectHidden = returns a Boolean indicating if the object is currently hidden or not
• bounds = returns a list of four space-separated numeric values that indicate the position
of the object on the layout, in the following order: top, left, bottom, right, rotation degrees;
based on the current object size and position that may change as a window is resized
• left = returns a number representing the left edge of the object on the layout; based
on the current object position that may change as a window is resized
• right = returns a number representing right-left edge of the object on the layout;
based on the current object position that may change as a window is resized
• top = returns a number representing the top edge of the object on the layout; based
on the current object position that may change as a window is resized
392
Chapter 21 ■ Logical Functions
• bottom = returns a number representing the bottom edge of the object on the layout;
based on the current object position that may change as a window is resized
• width = returns the width of the object; based on the current object size that may
change as a window is resized
• height = returns the height of the object; based on the current object size that may
change as a window is resized
• rotation = returns a number representing the rotation of the object (degrees)
• startPoint = returns two space-separated numeric values that indicate the start
position of a line or the upper-left corner of another object type in the following
order: top, left; based on the current object position that may change as a window is
resized
• endPoint = returns two space-separated numeric values that indicate the end
position of a line or the lower-right corner of other object types, in the following
order: bottom, right; based on the current object position that may change as a
window is resized
• source = returns a text string containing the source information of the object, varying
by type listed in Table 21-1
• content = returns a text string containing the content of object, varying by type listed
in Table 21-1
• enclosingObject = returns the name of the object that encloses the object specified
• containedObjects = returns a list of named objects contained by the object specified
Table 21-1. The result of the source and content attribute based on object type
393
Chapter 21 ■ Logical Functions
■■Caution The bounds, left, right, top, and bottom measurements returned by the
GetLayoutObjectAttribute function are based on the layout object’s position relative to the top-left corner of
the primary display’s desktop area and not the object’s position within a layout. That means that as a window is
moved around the screen, these values will change. This behavior is consistent with past versions of FileMaker
Pro for macOS but is a change for Windows.
GetNthRecord
The GetNthRecord function returns the contents of a field from a specified record within the found set
regardless of the current record.
This example would return the contents of the Full Name field from the fifth record in the found set
from the People table:
If
The If function conditionally returns a value depending on the outcome of a text expression. Although the
function can be nested to handle more than two results, the Case function is recommended.
Format When one conditional result is required, only two parameters must be included: a test
expression and a result to be returned if the test is true:
If ( test ; resultOne )
Where the above will return a null or blank result if the test is false, an optional second
result parameter can be included, which will be returned instead if the test is false:
If ( test ; resultOne; resultTwo)
Parameters test = a numeric value or logical expression that evaluates to a Boolean.
resultOne = a value will be returned if the test expression is true.
resultTwo = (optional) a value that will be returned if the test expression is false.
Result The appropriate result based on the value returned from the expression.
This simple example will determine if the date of an invoice is in the past or the future. If the value in
the Invoice record’s Date field is less than or equal to today’s date, the test expression will return true and
the function will return the word Past. If the date is greater than today’s date, the test expression will return
false and the function will return the word Future.
394
Chapter 21 ■ Logical Functions
IsEmpty
The IsEmpty function determines if a value is empty.
IsValid
The IsValid function determines if another field’s value is valid.
If the Invoice record’s Date Due calculation field is defined to contain a date and instead evaluates to a
number, it will return 0 (zero) indicating an invalid result:
IsValidExpression
The IsValidExpression function determines if an expression’s syntax is correct and will execute
successfully. This can be helpful to confirm the validity of some dynamically compiled code that will be sent
to the Evaluate function.
395
Chapter 21 ■ Logical Functions
This example will return a false result because the Get ( CurrentDate ) function in the text string is
missing a closing parenthesis and will not evaluate to a valid result:
Let
The Let function forms a statement in which one or more temporary variables can be named and initialized
and then used during the execution of a nested calculation formula. The function allows for the compression
of lengthy field names and expressions into shorter variables, which can then be used multiple times within
a complex formula. It also allows the un-nesting of complex formulas: separating shorter expressions and
putting them into variables one after the other and then using them together in a compressed formula.
Format When setting a single variable, two parameters are required: first, a combination parameter
of a variable, equal sign operator and expression; and second, a calculation formula:
Let ( var1 = expression ; calculation )
When multiple variables are required, they are added within a set of square brackets and
a semicolon delimiter (shown here in a preferred, optional multi-line format to improve
clarity):
Let ( [
var1 = expression1 ;
var2 = expression2 ;
var3 = expression3
] ;
calculation
)
Parameters var = the name of a calculation local variable, script local variable, or database local
variable.
expression = a field reference, constant, or expression, the result of which will be placed
into the corresponding variable.
calculation = a formula that has access to all the variables defined above.
Result The result of the calculation.
This is a simple example of a single variable being initialized as a text string and then returned as the result:
Let ( textString = "World" ; "Hello " & textString )) // result = "Hello World"
The following example has only one variable, but the calculation is more realistic. First, the value in the
Number of Days Overdue field is placed into a daysOver variable. The calculation portion of the statement
uses the Case function to create a text string with content that varies if daysOver is greater than 30 or not.
Notice how the field is used twice in the calculation by means of the shorter daysOver variable name.
396
Chapter 21 ■ Logical Functions
Let (
daysOver = Invoice::Number of Days Overdue
;
Case (daysOver > 30 ; "Past Due (" & daysOver & " days)" ; "Current" )
)
The following example demonstrates how a Let statement can be used to set global variables. This
example performs the same function and returns the same result as the previous one. The only difference
is that it puts the value from the Customer ID field into a global variable named $$LastCustomerID and it
increments the value in another global variable $$CustomerCount by 1.
Let ( [
$$LastCustomerID = Invoice::Customer ID ;
$$CustomerCount = $$CustomerCount + 1 ;
daysOver = Invoice::Number of Days Overdue
] ;
Case (daysOver > 30 ; "Past Due (" & daysOver & " days)" ; "Current" )
)
Expressions with the Let statement can get complex. Remember that this function can be nested within
other functions and other functions can be nested within its variable expressions and calculations.
Lookup
The Lookup function attempts to return a value from a related field through a specific relationship.
These examples assume two tables — Products (shown in Table 21-2) and Invoice Line Items — and
a relationship named Invoice Line | Product that connects them by the Product ID fields in each.
397
Chapter 21 ■ Logical Functions
If the Invoice Line Product Name was a calculation that will look up the product name when the user
types in a Product ID, the formula would look like this with the results shown depending on the values entered:
■■Caution This function is a somewhat outdated method for accessing related information. When defining
fields, the auto-enter calculation feature is preferable to lookups and any formula can reach through a
relationship and access-related values with ease.
LookupNext
Like Lookup, the LookupNext function attempts to return a value from a related field through a specific
relationship. However, it has a fail option that will automatically retrieve the next lower or higher value when
no exact match is found.
Using the same example from the Lookup function, the failure to find a match for a Product ID of 4 will
now retrieve the next lower value: Widget C, which has a Product ID of 3.
398
Chapter 21 ■ Logical Functions
Self
The Self-function returns the content of an object without naming or referring to it explicitly. This allows a
single calculation to be applied to many objects without modification since the reference to the object is the
function. The function can be used in layout calculations for conditional formatting, hiding layout objects,
and tooltips. It is also useful in the field definition as an auto-enter calculation for other field types.
Format Self
Parameters Not applicable
Result The contents of the object that are associated with the calculation using the function.
A field’s auto-enter formula, can clean up user-entered data with a formula like the example below,
which removes all text formatting, non-alphabetic characters, and extra spaces. If the user entered " M a
r k — M u n r o 1/5/2017 @ %$ ", their entry would instantly be cleaned up to "Mark Munro" helping to
ensure neat and consistent data entry.
Let ( [
entry = TextFormatRemove ( Self ) ;
entry = Filter ( entry ; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ) ;
entry = TrimAll ( entry ; 0 ; 0 )
] ;
entry
)
Summary
In this chapter, we explored all the built-in functions for performing logical calculations.
399
CHAPTER 22
Get Functions
Get functions provide a single piece of information about the computer’s system, the user’s environment,
the current database context, and the status of various processes or current settings. These are useful when
creating conditional formulas or scripts that return different results or perform a different task based on
some aspect of the current context or situation. They each require a single unchanging parameter — a
keyword that indicates the desired information.
Get ( <StaticParameter> )
• Get ( ConnectionAttributes )
• Get ( ConnectionState )
• Get ( CurrentDate )
• Get ( CurrentExtendedPrivileges )
• Get ( CurrentHostTimestamp )
• Get ( CurrentPrivilegeSetName )
• Get ( CurrentTime )
• Get ( CurrentTimestamp )
• Get ( CurrentTimeUTCMilliseconds )
• Get ( CustomMenuSetName )
• Get ( DesktopPath )
• Get ( Device )
• Get ( DocumentsPath )
• Get ( DocumentsPathListing )
• Get ( EncryptionState )
• Get ( ErrorCaptureState )
• Get ( FileMakerPath )
• Get ( FileName )
• Get ( FilePath )
• Get ( FileSize )
• Get ( FoundCount )
• Get ( HighContrastColor )
• Get ( HighContrastState )
• Get ( HostApplicationVersion )
• Get ( HostIPAddress )
• Get ( HostName )
• Get ( InstalledFMPlugins )
• Get ( LastError )
• Get ( LastExternalErrorDetail )
• Get ( LastMessageChoice )
• Get ( LayoutAccess )
• Get ( LayoutCount )
• Get ( LayoutNumber )
• Get ( LayoutTableName )
402
Chapter 22 ■ Get Functions
• Get ( LayoutViewState )
• Get ( MenubarState )
• Get ( ModifiedFields )
• Get ( MultiUserState )
• Get ( NetworkProtocol )
• Get ( NetworkType )
• Get ( PageNumber )
• Get ( PersistentID )
• Get ( PreferencesPath )
• Get ( PrinterName )
• Get ( QuickFindText )
• Get ( PrivilegeSetName )
• Get ( RecordAccess )
• Get ( RecordID )
• Get ( RecordModificationCount )
• Get ( RecordNumber )
• Get ( RecordOpenCount )
• Get ( RecordOpenState )
• Get ( RequestCount )
• Get ( RequestOmitState )
• Get ( ScreenDepth )
• Get ( ScreenHeight )
• Get ( ScreenScaleFactor )
• Get ( ScreenWidth )
• Get ( ScriptAnimationState )
• Get ( ScriptName )
• Get ( ScriptParameter )
• Get ( ScriptResult )
• Get ( SortState )
• Get ( StatusAreaState )
• Get ( SystemDrive )
• Get ( SystemIPAddress )
• Get ( SystemLanguage )
• Get ( SystemNICAddress )
403
Chapter 22 ■ Get Functions
• Get ( SystemPlatform )
• Get ( SystemVersion )
• Get ( TemporaryPath )
• Get ( TextRulerVisible )
• Get ( TotalRecordCount )
• Get ( TouchKeyboardState )
• Get ( TriggerCurrentPanel )
• Get ( TriggerExternalEvent )
• Get ( TriggerGestureInfo )
• Get ( TriggerKeystroke )
• Get ( TriggerModifierKeys )
• Get ( TriggerTargetPanel )
• Get ( UserCount )
• Get ( UserName )
• Get ( UseSystemFormatsState )
• Get ( UUID )
• Get ( WindowContentHeight )
• Get ( WindowContentWidth )
• Get ( WindowDesktopHeight )
• Get ( WindowDesktopWidth )
• Get ( WindowHeight )
• Get ( WindowLeft )
• Get ( WindowMode )
• Get ( WindowName )
• Get ( WindowOrientation )
• Get ( WindowStyle )
• Get ( WindowTop )
• Get ( WindowVisible )
• Get ( WindowWidth )
• Get ( WindowZoomLevel )
Get ( AccountExtendedPrivileges )
This function returns extended privileges assigned to the account used to authenticate the connection to the
database file.
404
Chapter 22 ■ Get Functions
Get ( AccountExtendedPrivileges )
= "fmapp"
Get ( AccountGroupName )
This function returns the account group name when the account is using an external server or OAuth
authentication method.
Get ( AccountName )
This function returns the account name used to authenticate the connection to the database file.
Get ( AccountPrivilegeSetName )
This function returns the name of the privilege set for the account used to authenticate the connection to the
database file.
Get ( AccountPrivilegeSetName )
= "[Full Access]"
405
Chapter 22 ■ Get Functions
Get ( ActiveFieldContents )
This function returns the contents of the field that has current focus in the front window.
This example assumes the user is viewing a record in a table named Contacts for a person named “John
Smith” and has the cursor in a field named Full Name:
Get ( ActiveFieldName )
This function returns the field that has current focus in the front window.
This example assumes the user is viewing a record in a table named Contacts for a person named “John
Smith” and has the cursor in a field named Full Name:
Get ( ActiveFieldTableName )
This function returns the table to which the field with focus belongs.
This example assumes the user is viewing a record in a table named Contacts for a person named “John
Smith” and has the cursor in a field named Full Name:
Get ( ActiveLayoutObjectName )
This function returns the name current active layout object: fields, buttons, portals, tabs, web viewers
(Chapter 31, “Naming Objects”).
406
Chapter 22 ■ Get Functions
This example shows the result from the function if active focus is on a portal with an assigned name of
“Invoice Portal”:
Get ( ActiveModifierKeys )
This function returns a value indicating which modifier key(s) the user is currently pressing.
This example indicates that the user is holding down the Control and Command keys on macOS.
This example uses several other functions to build a carriage return-delimited list of the names of every
modifier key held down at the time it is evaluated.
Let ( [
keys = Get ( ActiveModifierKeys ) ;
list = Case ( Mod ( keys; 32 ) ≥ 16 ; "Command¶" ; "" ) ;
list = list & Case ( Mod ( keys; 16 ) ≥ 8 ; "Option¶" ; "" ) ;
list = list & Case ( Mod ( keys; 8 ) ≥ 4 ; "Control¶" ; "" ) ;
list = list & Case ( Mod ( keys; 4 ) ≥ 2 ; "Caps Lock¶" ; "" ) ;
list = list & Case ( Mod ( keys; 2 ) ≥ 1 ; "Shift¶" ; "" )
] ;
list
)
Get ( ActivePortalRowNumber )
This function returns which portal row is currently selected.
407
Chapter 22 ■ Get Functions
Get ( ActiveRepetitionNumber )
This function returns the active field repetition of the field, which has focus in the front window.
Get ( ActiveSelectionSize )
This function returns the length in characters of selected text within the active field.
Get ( ActiveSelectionStart )
This function determines the character position at which a selection of text within a field begins in the front
window.
408
Chapter 22 ■ Get Functions
This example shows the function returning the number of characters that make up the selection:
This example uses several functions to extract the text of just the current selection from a field:
Let ( [
count = Get ( ActiveSelectionSize ) ;
start = Get ( ActiveSelectionStart ) ;
text = Get ( ActiveFieldContents )
] ;
Middle ( text ; start ; count )
)
Get ( AllowAbortState )
This function determines if the user has the option to abort a script or not.
Get ( AllowFormattingBarState )
This function determines if the formatting bar is able to be made visible or not.
Get ( ApplicationArchitecture )
This function return the architecture of the version of the application used to open the database file, which
can be useful if installing a plug-in that has processor-specific versions.
409
Chapter 22 ■ Get Functions
Get ( ApplicationLanguage )
This function returns the current language version of the application used to open the database file.
Get ( ApplicationVersion )
This function returns the product name and version for the current version of FileMaker Server used to open
the database file.
Get ( ApplicationVersion )
// = "Pro 16.0.1"
// = "ProAdvanced 16.0.1"
// = "Runtime 16.0.1"
// = "Web Publishing Engine 16.0.1"
// = "xDBC 16.0.1"
// = "Server 16.0.1"
// = "Go 16.0.1"
// = "Go_iPad 16.0.1"
410
Chapter 22 ■ Get Functions
Get ( CalculationRepetitionNumber )
This function returns the repetition of a repeating calculation field being evaluated. This is useful when each
repetition of a calculation field must pull a value from a corresponding repeating field or perform slightly
different functions depending on the repetition.
This example assumes a Start Date field with a value of 1/5/2017. A second calculation field with
five repetitions will display the dates of weekly reviews. Using this formula, each repetition will calculate a
different number of days to add based on an identification of its own position using this function.
Get ( ConnectionAttributes )
This function returns details about the connection to a host computer, assuring the connection is secure.
Get ( ConnectionAttributes )
// result =
[ Peer Certificate ]
commonName: office_server
CA issuers: ABC SSL Inc.
Get ( ConnectionState )
This function returns the security state of the connection to a database accessed across a network from a
host computer.
411
Chapter 22 ■ Get Functions
Get ( CurrentDate )
This function returns the current date.
Get ( CurrentExtendedPrivileges )
This function returns the name of the extended privileges enabled based on the user’s method of logging
into the database file.
Get ( CurrentHostTimestamp )
This function returns the current date and time of the host computer, which is useful if the client is located
in a different time zone than the server. Using this function in an unstored calculation that is visible on a list
layout may severely degrade the performance of your database since it will attempt to update the value for
every record in the found set each time the layout view is updated.
412
Chapter 22 ■ Get Functions
Get ( CurrentPrivilegeSetName )
This function returns the name of the privilege set based on the user’s method of logging into the
database file.
Get ( CurrentTime )
This function returns the current time.
Get ( CurrentTimestamp )
This function returns the current date and time.
Get ( CurrentTimeUTCMilliseconds )
This function returns the current time in Coordinated Universal Time (UTC) to the nearest millisecond
without regard to the current time zone. UTC was previously known as Greenwich Mean Time (GMT).
413
Chapter 22 ■ Get Functions
To calculate the time for a specific time zone, just factor in the UTC time zone adjustment for the region.
For example, New York City is five hours behind UTC during Eastern Standard Time, so this formula will
return the time adjusted for that region:
Let ( [
timeUTC = Get ( CurrentTimeUTCMilliseconds ) ;
timeNY = Round ( ( timeUTC + ( -5 * 3600000 ) ) / 1000 ; 0 )
] ;
GetAsTimestamp ( timeNY )
)
Get ( CustomMenuSetName )
This function returns the name of the active custom menu set (Chapter 33).
Get ( DesktopPath )
This function returns the path to the user’s local desktop folder.
Get ( DesktopPath )
// macOS result = /Macintosh HD/Users/admin/Desktop/
// Windows result = /C:/Users/Admin/Desktop/
414
Chapter 22 ■ Get Functions
Get ( Device )
This function returns the type of computer or device upon which the user is running a FileMaker Product.
Since the function is zero based, the best method to convert the result into the device name is to use the
Choose function.
It is also possible to do this with the GetValue function; however, you will need to add 1 to the result to
adjust it from zero-based to one-based, as shown in this example:
Get ( DocumentsPath )
This function returns the path to the documents folder. When the function is evaluated from a client version
of the software, it returns their local Documents folder. When evaluated by a FileMaker Server, it returns the
/FileMaker Server/Data/Documents/ folder.
415
Chapter 22 ■ Get Functions
Get ( DocumentsPath )
// Mac result = /Macintosh HD/Users/admin/Documents/
// Windows result = /C:/Users/admin/Documents/
Get ( DocumentsPathListing )
This function returns a list of every item within the user’s local documents folder, including all nested items.
Get ( DocumentsPathListing )
// result =
/Macintosh HD/Users/admin/Documents/Expense Reports/
/Macintosh HD/Users/admin/Documents/Expense Reports/Q1.xlsx
/Macintosh HD/Users/admin/Documents/To Do List.txt
Get ( EncryptionState )
This function returns a database file’s current encryption state.
This example shows the result when the file is not encrypted:
Get ( EncryptionState )
// result =
0
Get ( EncryptionState )
// result =
1
51836
416
Chapter 22 ■ Get Functions
Get ( ErrorCaptureState )
This function returns the state of error capture in scripts.
Get ( FileMakerPath )
This function returns the path to the local FileMaker Pro application running the database file.
Get ( FileMakerPath )
// macOS result = /Macintosh HD/Applications/FileMaker Pro 16/
// Windows result = /C:/Program Files/FileMaker/FileMaker Pro 16/
Get ( FileName )
This function returns the name of the current database file.
This example shows the result when the function is performed within a database file named Contacts.
fmp12:
Get ( FilePath )
This function returns the path to the current database file.
417
Chapter 22 ■ Get Functions
If the database is accessed from a folder directory, the result will be a path to the file:
Get ( FilePath )
// macOS result = /Macintosh HD/Users/admin/Documents/Contacts.fmp12
// Windows result = /C:/Users/admin/Documents/Contacts.fmp12
If the database is accessed from across the network to a host computer and the function evaluates on
the local client computer, the result will be in the form of a fmurl:
Get ( FileSize )
This function returns the file size of the current database.
Get ( FileSize )
= 352256
To convert the value to megabytes, divide the result and round it:
Get ( FoundCount )
This function returns the number of records in the found set of the current window.
Get ( HighContrastColor )
This function returns the current high-contrast, default color scheme name if an option is enabled and
selected in Windows Ease of Access Center.
418
Chapter 22 ■ Get Functions
Get ( HighContrastState )
This function determines if High Contrast is available and active in Windows Ease of Access Center.
Get ( HostApplicationVersion )
This function returns the product name and version for the current database file’s host from which the file
is being accessed across a network. The host might be a copy of FileMaker Pro, FileMaker Pro Advanced, or
FileMaker Server. If the file is running locally (unhosted), the function will return an empty value.
Get ( HostApplicationVersion )
// = Pro 16.0.1
// = ProAdvanced 16.0.1
// = Server 16.0.1
Get ( HostIPAddress )
This function returns the IP Address for the current database file’s host FileMaker Server. The result will be
an empty string if the current database is not hosted.
419
Chapter 22 ■ Get Functions
Get ( HostName )
This function returns the name of the current database file’s host FileMaker Server as displayed in the
macOS System Preferences or Windows Control Panel.
Get ( InstalledFMPlugins )
This function returns a list of installed plug-ins.
Get ( InstalledFMPlugins )
// result =
ExamplePlugin;2.4;Enabled
HypotheticalPlugin;1.3;Enabled
UselessPlugin;1.0;Disabled
VersionlessPlugin; ;Enabled
Get ( LastError )
This function returns the error number of the most recently executed script step.
420
Chapter 22 ■ Get Functions
Get ( LastError )
// Field is missing result = 102
// Record access is denied result = 200
// Unable to create file on disk result = 800
Get ( LastExternalErrorDetail )
This function returns details about errors that occur externally to FileMaker.
Get ( LastMessageChoice )
This function returns a number indicating the button clicked in a dialog created with the Show Custom
Dialog script step (Chapter 35). This allows a script to perform a different action depending on which button
the user clicks.
Get ( LayoutAccess )
This function returns the current level of access the user has to records on the current layout.
421
Chapter 22 ■ Get Functions
Get ( LayoutCount )
This function returns a count of all the layouts in the current database file.
Get ( LayoutName )
This function returns the name of the layout displayed in the current window.
Get ( LayoutNumber )
This function returns the number of the layout displayed in the current window.
Get ( LayoutTableName )
This function returns the name of the table for the layout of the current window.
422
Chapter 22 ■ Get Functions
Get ( LayoutViewState )
This function returns the current window’s layout view state.
Get ( MenubarState )
This function determines the current status of the menu bar in FileMaker Go or FileMaker WebDirect.
Get ( ModifiedFields )
This function returns a list of fields for the current table that have been modified since the last time the
current record was committed: the equivalent of unsaved changes.
423
Chapter 22 ■ Get Functions
Get ( ModifiedFields )
// result =
First Name
Last Name
Status
Get ( MultiUserState )
This function shows the sharing status of the current file on the network.
Get ( NetworkProtocol )
This function returns the network protocol that FileMaker is using on the local computer.
Get ( NetworkType )
This function returns the current network connection when using FileMaker Pro on an iOS device. This
allows a database to vary behavior depending on the connection type and potentially save a user bandwidth
charges for excessive data use.
424
Chapter 22 ■ Get Functions
Get ( PageNumber )
This function returns the number of the current page when printing or previewing.
Get ( PersistentID )
This function returns a unique identifier for the device used to access the database file.
Get ( PreferencesPath )
This function returns the path to the user’s local preferences folder.
425
Chapter 22 ■ Get Functions
Get ( PreferencesPath )
// macOS result = /Macintosh HD/Users/admin/Library/Preferences/
// Windows result = /C:/Users/Admin/AppData/Local/
Get ( PrinterName )
This function returns the name of the default printer.
Get ( QuickFindText )
This function returns the text that is currently entered in the Quick Find text box in the toolbar.
Get ( RecordAccess )
This function returns a value indicating the user’s access to the current record based on the privilege settings
of the account they used to log into the database.
426
Chapter 22 ■ Get Functions
Get ( RecordID )
This function returns the unique FileMaker ID for the current record.
Get ( RecordModificationCount )
This function returns a count of the total number of times a particular record has been modified and
committed.
Get ( RecordNumber )
This function returns the current record’s position within the found set of the current window.
Get ( RecordOpenCount )
This function returns the number of records (local and related) in the current window that have
uncommitted modifications.
427
Chapter 22 ■ Get Functions
Get ( RecordOpenState )
This function returns the current state of a record indicating if it is committed (closed), new, or modified.
Get ( RegionMonitorEvents )
This function returns information about events that triggered the script specified by a Configure Region
Monitor Script step monitoring for iBeacon encounters.
This examples shows results that indicate that the iOS device entered the region of an iBeacon named
StoreBeacon at 3:24 PM on March 15, 2017, and then exited the region 20 minutes later.
Get ( RegionMonitorEvents )
// result =
StoreBeacon
15/3/2017 3:24 PM;1
15/3/2017 3:44 PM;0
Get ( RequestCount )
This function returns a count of the number of find requests defined in the current window.
428
Chapter 22 ■ Get Functions
Get ( RequestOmitState )
This function indicates whether omit is selected for the current find request or not.
Get ( ScreenDepth )
This function returns the color depth of the main script, which is the number of bits required to represent
the color of a single pixel.
Get ( ScreenHeight )
This function returns the height of the computer’s monitor screen.
429
Chapter 22 ■ Get Functions
Get ( ScreenScaleFactor )
This function returns the scale factor of the current device screen.
Get ( ScreenWidth )
This function returns the width of the computer’s monitor screen.
Get ( ScriptAnimationState )
This function returns the current layout animation setting (FileMaker Go only).
Get ( ScriptName )
This function returns the name of the script that is currently running or paused.
430
Chapter 22 ■ Get Functions
Get ( ScriptParameter )
This function returns the parameter that was passed to the current script.
This example detects the absence of a script parameter and displays an error.
■■Note Script parameters and results are discussed in Chapter 34, “Exchanging Data Between Scripts.”
Get ( ScriptResult )
This function returns the result to a script from the last sub-script that it ran.
This function shows a script using an If statement to take conditional action depending on the results
from a sub-script. For example, an error in the sub-script might require a different course of action or an alert
dialog for the user. This can be accomplished by placing a few extra script steps after a Perform Script step.
431
Chapter 22 ■ Get Functions
Get ( SortState )
This function returns the current sort state of the found set of records in the current window.
■■Note When records are imported into a found set of sorted records, it will result in a semi-sorted state,
meaning that some records are sorted and some are not. A script can use this function to determine such a
state and use the Sort script step to resort the records.
Get ( StatusAreaState )
This function returns the current state of the status toolbar.
Get ( SystemDrive )
This function returns the name of the hard drive running the current operating system.
432
Chapter 22 ■ Get Functions
Get ( SystemIPAddress )
This function returns a list of active Internet Protocol (IP) addresses for the current computer. The results
may include multiple addresses if the computer is connected to multiple networks, such as Ethernet and
WiFi.
Get ( SystemIPAddress )
// result =
10.0.1.27
10.0.1.5
Get ( SystemLanguage )
This function returns the name of the language set for the computer in the macOS System Preferences,
Windows Control Panel, or the language of the Web Browser in WebDirect.
Get ( SystemNICAddress )
This function returns the hardware address of all installed Network Interface Controller (NIC) circuit board
cards that allow the current user’s computer to be connected to a network. This can identify the specific
hardware that a user is accessing a database from.
433
Chapter 22 ■ Get Functions
Get ( SystemNICAddress )
// result =
4c:37:04:1j:67:2b
dc:be:88:10:71:c2
f6:9f:64:44:hd:12
8e:00:5d:10:k7:00
8e:00:5d:10:k7:01
8e:00:5d:10:k7:04
8e:00:5d:10:k7:05
Get ( SystemPlatform )
This function returns the platform of the current device and can be used to create branching scripts that
provide different functionality depending on the device.
Get ( SystemVersion )
This function returns the version number of the current operating system or device.
Get ( TemporaryPath )
This function returns a path to an temporary session folder automatically generated by FileMaker Pro
application and the computer system on which it is running. This path can be used as a staging location
to which to export files that will be emailed or otherwise processed when ready. Once the FileMaker
application is shut down, the folder is automatically deleted.
434
Chapter 22 ■ Get Functions
Get ( TemporaryPath )
// result = /Macintosh HD/var/folders/79/4gh7yxxj7zd1xpd2dcqm0qw80000gn/T/S10/
Get ( TextRulerVisible )
This function indicates if the text ruler is visible or hidden.
Get ( TotalRecordCount )
This function returns the total count of records in the current table.
Get ( TouchKeyboardState )
This function determines if the touch keyboard will be displayed automatically when needed or not. This
feature is only supported in FileMaker Go and Windows.
435
Chapter 22 ■ Get Functions
Get ( TriggerCurrentPanel )
This function will return information about the panel being switched from when using the OnPanelSwitch
script trigger (Chapter 37). This allows a script to identify which panel the user was on prior to requesting
navigation to a different one.
This example assumes a tab control named Contact Details with four tabs and an OnPanelSwitch
script trigger that runs a script with a step containing the formula below. The user, viewing tab 3, clicks
on tab 1. The result will be the number of the tab they were viewing (3) and the name of that tab control
(Contact Details) as shown here:
Get (TriggerCurrentPanel)
// result =
3
Contact Details
Get ( TriggerExternalEvent )
This FileMaker Go function returns a number indicating the event that activated an
OnExternalCommandReceived script trigger (Chapter 37).
436
Chapter 22 ■ Get Functions
Get ( TriggerGestureInfo )
The Get ( TriggerGestureInfo ) function returns information about a gesture on an iOS or Windows device
that activates the OnGestureTap script trigger (Chapter 37).
Get ( TriggerKeystroke )
// result =
Tap
1
2
185
312
Get ( TriggerKeystroke )
This function returns the character that activated an OnObjectKeystroke or OnLayoutKeystroke script
trigger (Chapter 37).
Get ( TriggerModifierKeys )
This function returns the modifier keys that were held down at the moment the script trigger was activated.
This function returns the same information as Get ( ActiveModifierKeys ) but may be received after the
user has already let go of the keys so it is more useful when running a script trigger.
437
Chapter 22 ■ Get Functions
Get ( TriggerTargetPanel )
This function will return information about the panel being switched to when using the OnPanelSwitch
script trigger (Chapter 37). This allows a script to identify which panel the user has clicked on.
This example assumes a tab control named Contact Details with four tabs and an OnPanelSwitch
script trigger that runs a script with a step containing the formula below. The user, viewing tab 3, clicks
on tab 1. The result will be the number of the tab they were viewing (3) and the name of that tab control
(Contact Details) as shown here:
Get (TriggerTargetPanel)
// result =
1
Contact Details
Get ( UserCount )
This function returns the number of users actively connected to a database file.
Get ( UserName )
This function returns the name of the current user, which is specified in Preferences.
438
Chapter 22 ■ Get Functions
Get ( UseSystemFormatsState )
This function indicates if the Format > Use System Formats format menu bar is on or off (Chapter 3, “File
Options”).
Get ( UUID )
This function generates a Universally Unique Identifier (UUID), which is a non-guaranteed unique id
number that can be used to decentralize certain aspects of database record tracking. If used as the primary
key for database records, users in a duplicate file who are in a remote location or offline could create new
records without causing duplicate ids when their records are later imported into the central database.
Get ( WindowContentHeight )
This function returns the height of the visible content area of the current window.
439
Chapter 22 ■ Get Functions
Get ( WindowContentWidth )
This function returns the width of the visible content area of the current window.
Get ( WindowDesktopHeight )
This function returns the height of the computer’s desktop space.
Get ( WindowDesktopWidth )
This function returns the width of the computer’s desktop space.
Get ( WindowHeight )
This function returns the height of the current window.
440
Chapter 22 ■ Get Functions
Get ( WindowLeft )
This function returns the distance from the left of the screen to the outside left of the current window.
Get ( WindowMode )
This function returns the mode of the current window.
Get ( WindowName )
This function returns the name of the current window.
441
Chapter 22 ■ Get Functions
Get ( WindowOrientation )
This function returns the orientation of the current window, which can be most useful with FileMaker Go on
a tablet or phone that can be rotated into different views.
Get ( WindowStyle )
This function returns the style of the current window.
Get ( WindowTop )
This function returns the distance from the bottom of the menu bar to the outside top of the current window.
442
Chapter 22 ■ Get Functions
Get ( WindowVisible )
This function determines if the current window is visible or not.
Get ( WindowWidth )
This function will return the width of the current window.
Get ( WindowZoomLevel )
This function returns the zoom percentage of the current window.
Summary
In this chapter, we explored all the built-in functions for accessing many different static values.
443
CHAPTER 23
Design Functions
Design functions are used to acquire information about the structure of a database file.
DatabaseNames
The DatabaseNames function returns a list of database files currently open.
Format DatabaseNames
Parameters Not applicable.
Result A carriage return-delimited list of open database names.
DatabaseNames
// result =
Contacts
Invoices
Projects
FieldBounds
The FieldBounds function returns the location of a field on a layout.
Combine this result with other functions to calculate the width and height of the field. The example
below places the field bounds into a variable named data and uses the GetValue function to parse each
measurement into a separate variable. These are then used to calculate the width and height and place
them each into a variable that can then be used by other code.
Let ( [
fieldName = GetFieldName ( People::First Name ) ;
data = FieldBounds ( "Contacts" ; "People – Data Entry" ; fieldName ) ;
left = GetValue ( data ; 1 ) ;
top = GetValue ( data ; 2 ) ;
right = GetValue ( data ; 3 ) ;
446
Chapter 23 ■ Design Functions
■■Tip To help future-proof your code, use dynamic references when functions require a file or field name.
Use Get ( FileName ) instead of “Contacts” and GetFieldName ( People::First Name ) instead of
“People::First Name” to allow your code to dynamically adapt to future name changes.
FieldComment
The FieldComment function returns the comment for a field from the field definitions dialog, if one
has been entered.
FieldIDs
The FieldIDs function returns a list of the FileMaker ids of every field on a layout.
447
Chapter 23 ■ Design Functions
FieldNames
The FieldNames function returns a list of the name of every field on a layout.
FieldRepetitions
The FieldRepetitions function returns the number and orientation of repetitions applied to a field on a
layout.
448
Chapter 23 ■ Design Functions
FieldStyle
The FieldStyle function returns the formatting applied to a field on a layout.
FieldType
The FieldType function returns information about a field including data type, index status, storage settings,
and number of repetitions.
449
Chapter 23 ■ Design Functions
The function can be combined with other functions to extract specific values. This example uses a Let
statement to place the field’s information into a variable named data and then uses the GetValue function to
parse the various components into separate variables:
Let ( [
data = FieldType ( Get ( FileName ) ; GetFieldName ( Example Input ) ) ;
data = Substitute ( data ; " " ; "¶" ) ;
storage = GetValue ( data ; 1 ) ;
type = GetValue ( data ; 2 ) ;
index = GetValue ( data ; 3 ) ;
repetitions = GetValue ( data ; 4 )
] ;
// Add additional code
)
GetNextSerialValue
The GetNextSerialValue function returns the next serial number for a field.
LayoutIDs
The LayoutIDs function returns a list of the ID of every layout in a database file.
450
Chapter 23 ■ Design Functions
LayoutIDs ( "Contacts" )
// result =
1
2
5
10
12
13
LayoutNames
The LayoutNames function returns a list of the names of every layout in a database file.
LayoutNames ( "Contacts" )
// result =
Company - List
People – List
People – Data Entry
People – Notes
Correspondence – List
Phone Numbers - List
LayoutObjectNames
The LayoutObjectNames function returns a list of the names of every named object on a layout.
451
Chapter 23 ■ Design Functions
RelationInfo
The RelationInfo function returns data on the relationship(s) connected to a specified table.
Source:Contacts
Table:Person | Correspondence
Options:
Person::Record ID = Person | Correspondence::Record Parent ID
Person::Person Correspondence Status = Person | Correspondence::Record Status
452
Chapter 23 ■ Design Functions
ScriptIDs
The ScriptIDs function returns a list of the ID of every script in a database file.
ScriptIDs ( "Contacts" )
// result =
9
14
15
26
ScriptNames
The ScriptNames function returns a list of the names of every script in a database file.
ScriptNames ( "Contacts" )
// result =
Create New Contact
Create New Correspondence
Find Contacts at the Same Company
Etc.
TableIDs
The TableIDs function returns a list of the IDs of every table in a database file.
453
Chapter 23 ■ Design Functions
TableIDs ( "Contacts" )
// result =
2
4
10
11
TableNames
The TableNames function returns a list of the names of every table in a database file.
TableNames ( "Contacts" )
// result =
Company
Contact
Phone Numbers
Correspondence
ValueListIDs
The ValueListIDs function returns a list of the IDs of every values list in a database file.
ValueListIDs ( "Contacts" )
// result =
1
15
18
31
454
Chapter 23 ■ Design Functions
ValueListItems
The ValueListItems function returns a list of the values that make up a value list.
Create a more dynamic approach by nesting other functions. This example will get a list of value list
names for the current file and then get the items for the first three lists:
Let ( [
lists = ValueListNames ( Get ( FileName ) ) ;
items1 = ValueListItems ( GetValue (lists ; 1 ) ;
items2 = ValueListItems ( GetValue (lists ; 2 ) ;
items3 = ValueListItems ( GetValue (lists ; 3 )
] ;
// additional code
)
ValueListNames
The ValueListNames function returns a list of the names of every values list in a database file.
ValueListNames ( "Contacts" )
// result =
Status
Phone Types
Industry List
Salutation Options
455
Chapter 23 ■ Design Functions
WindowNames
The WindowNames function returns a list of the names of open FileMaker Pro windows.
WindowNames
// result =
Contacts
Phone Numbers
Correspondence
Invoices
Projects
WindowNames ( "Contacts" )
// result =
Contacts
Phone Numbers
Correspondence
Summary
In this chapter, we explored all the built-in functions for accessing various design information.
456
CHAPTER 24
Mobile Functions
Mobile functions are used to get information that is specific to a mobile device running a database on
FileMaker Go.
Location
The Location function returns the location of an iOS device running FileMaker Go.
Location ( 100 ; 70 )
// result =
50.682532, -85.915032, 5
To extract a value from these results, combine this with other functions:
Let ( [
data = Location ( 100 ; 70 ) ;
data = Substitute ( data ; "," ; "¶" )
latitude = GetValue ( data ; 1 ) ;
longitude = GetValue ( data ; 2 ) ;
accuracyHorizontal = GetValue ( data ; 3 )
] ;
// Add additional code here
)
■■Tip To maximize speed and avoid battery consumption when using Location and LocationValues, use
larger accuracy and smaller timeouts. It can take 40 seconds to return accuracy to 100 meters.
LocationValues
The LocationValues function returns a list of values containing the latitude, longitude, and altitude of an
iOS device running FileMaker Go, including an evaluation of accuracy and minutes since the values were
returned.
458
Chapter 24 ■ Mobile Functions
LocationValues ( 5 )
// result =
50.682532
-85.915032
5
8
0.004355
To extract a value from these results, combine this with other functions:
Let ( [
data = LocationValues ( 5 ) ;
latitude = GetValue ( data ; 1 ) ;
longitude = GetValue ( data ; 2 ) ;
accuracyHorizontal = GetValue ( data ; 3 ) ;
accuracyVertical = GetValue ( data ; 4 ) ;
age = GetValue ( data ; 5 )
] ;
// Add additional code here
)
RangeBeacons
The RangeBeacons function returns a list of iBeacons and their proximity to an iOS device. iBeacons use
Bluetooth Low Energy (BLE) to establish a region around an object, allowing iOS devices to determine when
it has entered or left the region, along with an estimation of proximity to a beacon.
459
Chapter 24 ■ Mobile Functions
Result a carriage return-delimited list of nearby iBeacons with the following comma-space
delimited values for each:
UUID = the id of the current iBeacon.
major = a value identifying the group of iBeacons.
minor = a value indentifying specific iBeacons within the group.
proximity = a number representing the proximity of the device to an iBeacon, from 0
to 3 indicating: Unknown, Immediate, Near, Far.
accuracy = a number representing the accuracy in meters of the proximity value with
any negative value indicating accuracy was indeterminate.
rssi = a number representing the received signal strength in decibels of the iBeacon.
More Info For more information about iBeacons visit:
https://developer.apple.com/ibeacon/.
RangeBeacons ( "W5T5M11J-AAAA-BBBB-23T4-5H55A5BCD55E" )
// result =
W5T5M11J-AAAA-BBBB-23T4-5H55A5BCD55E, 1, 1, 2, 10, 5
W5T5M11J-AAAA-BBBB-23T4-5H55A5BCD55E, 1, 2, 3, 6, 3
W5T5M11J-AAAA-BBBB-23T4-5H55A5BCD55E, 2, 5, 0, -13, 2
Summary
In this chapter, we explored all the built-in functions for accessing information on a mobile device.
460
CHAPTER 25
■■Note Custom functions can only be created and edited within the FileMaker Pro Advanced application.
However, once a function is installed in a database file using this application, they can be accessed and used by
calculations and scripts running a database with any other application in the FileMaker family of software.
2 3 4 5 6 7 8
To open this dialog, select the File > Manage > Custom Functions menu item.
462
Chapter 25 ■ Creating Custom Functions
This dialog displays a list of all custom functions installed in the current database file. From here functions
can be viewed, sorted, created, edited, duplicated, deleted, and imported using the following controls:
1.
Function list — This area displays every function installed in the current
database file. The list can be sorted by clicking on one of the three column
headings or by selecting one of the following options from the View by pop-up
list in the upper-right corner:
• Creation Order
• Function Name
• Custom Order where the functions can be sorted by dragging items up or down
the list
2.
New — This button will open a new Edit Custom Function dialog.
3.
Edit — This button will open the selected function in the Edit Custom Function
dialog.
4.
Duplicate — This button will create a duplicate copy of the selected function(s).
5.
Delete— This button will delete the selected function(s).
6.
Import— This button will allow one or more custom functions from a selected
database to be imported into the current database.
7.
Cancel — This button will close the dialog window with a warning that no
changes will be saved.
8.
OK — This button will close the dialog window, saving all changes.
463
Chapter 25 ■ Creating Custom Functions
2
5
7 8 9
To open this window, click on the New button on the Manage Custom Functions dialog.
The Edit Custom Function dialog contains the following controls:
1.
Function Name — This text area contains the name of the function, which will be
used to call the function from other formulas.
2.
Parameter Name — This text area contains the name of a new or currently
selected parameter. Once a parameter name is entered or modified, the
parameter can be created, updated, or deleted using the adjacent buttons.
3.
Parameter List — This area contains the list of every parameter defined for the
function. These can be rearranged by dragging up or down the list. Parameters
are positional, so values included as parameters in a call to the function in other
formulas will be inserted into the parameter at the corresponding position
shown here. Changing the order of parameters will require rearranging the
values in every existing call to the function for them to be inserted into the
correct variable.
464
Chapter 25 ■ Creating Custom Functions
4.
Operators — This area contains controls for the quick insertion of an operator
into the code. The most popular operators are included as two rows of buttons
with the remaining available in a list. A single-click on a button or a double-click
on a list item will insert the corresponding operator into the current selection
point of the function’s formula.
5.
Functions — This area contains a list of functions. By default, all functions are
displayed sorted by name. However, the pop-up menu above the list contains
options to display them categorized by type or to filter the list to a single
category. The list not only includes all built-in functions but also any other
custom functions and external functions from any installed plug-ins.
6.
Formula Text Area — This text area is where the calculation formula is written.
As with the standard Specify Calculation dialog, you can type, drag/drop, copy/
paste, or insert content by double-clicking on the parameter or function list.
7.
Availability — By default, any new custom function will be accessible to all
accounts. However, selectively you can choose to make a function accessible to
only accounts with full access (Chapter 40).
8.
Cancel — This button will close the dialog window without saving changes.
9.
OK — This button will close the dialog window, saving all changes.
Let ( [
dateToday = Get ( CurrentDate ) ;
numAdjustment = DayOfWeek (dateToday) - 2
] ;
dateToday - numAdjustment
)
465
Chapter 25 ■ Creating Custom Functions
Once saved, any formula can call the function. Test this in the Sandbox table by following these steps:
1.
Open the Fields tab for the Sandbox table in the Manage Database dialog.
2.
Double-click the Example Calculation field or select it and click the
Options button.
3.
Change the field’s formula to GetMonday.
4.
Change the field’s Calculation result type to date.
5.
Click OK to save the calculation formula and close the Specify Calculation
dialog.
6.
Click OK to save and close the Manage Database dialog.
7.
View the result on the Sandbox Form layout for any record.
466
Chapter 25 ■ Creating Custom Functions
If the calculation containing this function call were evaluated on January 5, 2017, a Thursday, the
result should be the preceding Monday, 1/2/2017.
■■Tip When choosing a name for a parameter, be sure to give it an adequate amount of thought. There is
no way to restrict the type of data a calling formula passes into a parameter, so be sure to choose a name that
clearly describes the intended data type(s) to avoid developer confusion and errors. For example, a parameter
named input is too vague so consider using dateToProcess instead to clearly state what type of data it is
expecting. Look at built-in function parameters for guidance on this topic.
Let ( [
dateToProcess = GetAsDate ( dateInput ) ;
numAdjustment = DayOfWeek ( dateToProcess ) - 2
] ;
dateToProcess - numAdjustment
)
Once this code is entered, the custom function should appear as shown in Figure 25-4. To save it, click
the OK button.
467
Chapter 25 ■ Creating Custom Functions
Now modify the formula in the Example Calculation to refer to the new GetMonday2 function. Since
the function converts the input to a date automatically, the parameter can be any of the following:
• A text field containing a date value — GetMonday2 ( Sandbox::Example Text )
• A date field — GetMonday2 ( Sandbox::Example Date )
• A literal text string containing a date — GetMonday2 ( "1/5/2017" )
• A date value built with a function — GetMonday2 ( Date ( 1 ; 5 ; 2017 ) )
Depending on the date provided to the function in the new parameter, the result should be the Monday
relative to that date.
468
Chapter 25 ■ Creating Custom Functions
The code will need some changes to accommodate the desired functionality, as shown highlighted here:
Let ( [
dateToProcess = GetAsDate ( dateInput ) ;
list = "Sunday¶Monday¶Tuesday¶Wednesday¶Thursday¶Friday¶Saturday" ;
list = Left ( list ; Position ( list ; dayRequested ; 1; 1 ) ) ;
dayNumber = ValueCount ( list ) ;
numAdjustment = DayOfWeek ( dateToProcess ) - dayNumber
] ;
dateToProcess - numAdjustment
)
A new list variable is first initialized to contain a carriage return-delimited list of weekday names,
which will be used to determine where in the week the requested day falls. In the next line, list is modified
using the Left and Position functions to include only the days prior to the day name being requested.
Finally, the ValueCount function is used to determine the number of days remaining in the list, which is
placed into the dayNumber variable. This is used to determine the numAdjustment value in a manner like the
other versions of this function.
Once the new function is saved, modify the formula in the Example Calculation to refer to the new
GetDay function. In this example, the result will be the date of Friday for the week that January 5, 2017,
falls within:
The pattern of progression through these three expanding steps demonstrates the true power of custom
functions. They allow the development of open-ended formulas that can be used repeatedly with parameter-
driven variability.
By modifying the first line of the Let statement from the last example to include a condition to default
to the current date when none is provided, the formula can pass an empty string instead and still receive a
result.
Modify the first line with a Case statement that uses the current date if dateInput is empty or the date
provided if dateInput has a value, as shown here:
Now, a formula can request a day relative to the curent date by passing in an empty string in the first
parameter:
469
Chapter 25 ■ Creating Custom Functions
Let ( [
dateInput = Date ( 1 ; 15 ; 2017 )
] ;
"Input = " & dateInput & " (" & DayName (dateInput) & ")¶" &
"+1 Sunday=" & GetDay ( dateInput + 1 ; "Sunday" ) & "¶" &
"+2 Sunday=" & GetDay ( dateInput + 2 ; "Sunday" ) & "¶" &
"+3 Sunday=" & GetDay ( dateInput + 3 ; "Sunday" ) & "¶" &
"+4 Sunday=" & GetDay ( dateInput + 4 ; "Sunday" ) & "¶" &
"+5 Sunday=" & GetDay ( dateInput + 5 ; "Sunday" ) & "¶" &
"+6 Sunday=" & GetDay ( dateInput + 6 ; "Sunday" ) & "¶" &
470
Chapter 25 ■ Creating Custom Functions
// result =
Input = 1/15/2017 (Sunday)
+1 Sunday=1/15/2017
+2 Sunday=1/15/2017
+3 Sunday=1/15/2017
+4 Sunday=1/15/2017
+5 Sunday=1/15/2017
+6 Sunday=1/15/2017
Sunday=1/15/2017
Monday=1/16/2017
Tuesday=1/17/2017
Wednesday=1/18/2017
Thursday=1/19/2017
Friday=1/20/2017
Saturday=1/21/2017
Timestamp=1/15/2017
Text Date=1/15/2017
Text TS=1/15/2017
The formula uses a Let statement to make repeated calls to the GetDay function with a variety of
different input, placing each result in a variable. It then concatenates those variables into a single string. It is
important to change the Example Calculation field’s Calculation result to Text for this result for it to be
displayed properly in the field.
The first six results show that, as the dateInput is incremented to cover an entire week, the resulting
value for the requested Sunday is the same. The next seven results show that using the same dateInput while
requesting a different day of the week works since the results span a seven-day period. Finally, the last three
results show that when the dateInput is a timestamp, text-based date, or text-based timestamp, the result is
always the same.
With this test completed, it should now be safe to use this custom function with a wide variety of input.
471
Chapter 25 ■ Creating Custom Functions
function ( )
Figure 25-5. An illustration of a function calling itself recursively four times after the initial call from
another formula
Let ( [
current = GetValue ( numberList ; 1 ) ;
remaining = RightValues ( numberList ; ValueCount ( numberList ) - 1 )
] ;
current + Case ( remaining = "" ; 0 ; AddNumbers ( remaining ) )
)
In this example, the Let statement first splits the input in numberList into two variables. The first,
named current, is initialized to contain the first number in the numberList. The second, named remaining,
is initialized to contain any remaining numbers after the first one. In the calculation portion of the
statement, the number in current is added to the result of a Case statement, which is either an exit condition
returning zero or a recursive call to the function if there are numbers left within the remaining variable.
472
Chapter 25 ■ Creating Custom Functions
Once created and saved, the function can be called as follows with any quantity of carriage return-
delimited numbers and it will return the total of these, as shown in this example:
Once each iteration is complete, its current value must be held in place until the final number in the list
is reached, and then each number is added in reverse as the stack is collapsed back up to produce a result.
So, this example is limited to 10,000 iterations instead of 50,000. While this limit usually far exceeds
the needs of most custom functions, it is a good idea to be aware of how to work around it. In this case, the
function can be converted to use tail-recursion with a local variable.
473
Chapter 25 ■ Creating Custom Functions
With a couple of quick changes, the AddNumbers function can be converted to use a local variable
named $Total to store the running total of values and freeing itself from the head-recursion limitation.
These changes are highlighted in this example:
Let ( [
current = GetValue ( numberList ; 1 ) ;
$Total = $Total + current ;
remaining = RightValues ( numberList ; ValueCount ( numberList ) - 1 )
] ;
Case ( remaining = "" ; $Total ; AddNumbers ( remaining ) )
)
In each iteration of this revised version, the current number is added to the running total leaving the
Case statement to either return that total as the result or call the next recursive iteration. Since there is
nothing else remaining to be added or processed, FileMaker does not need to add anything to the call stack
and can, therefore, handle substantially more recursive loops.
Combining this statement with the original code and our test code from the previous examples, we can
duplicate the GetDay function to create a new function called GetDay2 with the same two parameters but
containing the following code:
Let ( [
dateInput = Date ( 1 ; 15 ; 2017 )
] ;
"Input = " & dateInput & " (" & DayName (dateInput) & ")¶" &
"+1 Sunday=" & GetDay ( dateInput + 1 ; "Sunday" ) & "¶" &
"+2 Sunday=" & GetDay ( dateInput + 2 ; "Sunday" ) & "¶" &
"+3 Sunday=" & GetDay ( dateInput + 3 ; "Sunday" ) & "¶" &
"+4 Sunday=" & GetDay ( dateInput + 4 ; "Sunday" ) & "¶" &
"+5 Sunday=" & GetDay ( dateInput + 5 ; "Sunday" ) & "¶" &
"+6 Sunday=" & GetDay ( dateInput + 6 ; "Sunday" ) & "¶" &
474
Chapter 25 ■ Creating Custom Functions
Now, if the dateInput receives a value of "Test" it will perform the test routine; otherwise it will assume
the parameter contains a date and will perform its normal function.
To test its normal operations, enter the following formula for the Example Calculation field of the
Sandbox table and make sure it is set to return a date value:
To trigger the function's test mode operations, enter the following formula for the Example Calculation
field of the Sandbox table and make sure it is set to return a text value:
This should return the same results we received in the previous test example.
■■Tip This example illustrates that recursion shouldn’t be thought of as only a looping phenomenon but a
self-referencing one. It is possible to create recursive functions with multiple modes that self-refer for a variety
of different functions.
Summary
In this chapter, we discussed the powerful benefits of developing your own custom functions.
475
CHAPTER 26
Introducing ExecuteSQL
The Structured Query Language (SQL) is a standardized programming language that is used to manage
relational databases and perform numerous operational functions to the data they store. SQL was initially
created in the 1970s and soon became the standard programming language for relational databases. The
American National Standards Institute (ANSI) and the International Organization for Standardization (ISO)
adopted an official SQL standard in 1986 and 1987 respectively. Since then, many updates to the standard
have been released jointly by both organizations, with the most recent version adopted in December of 2011.
Numerous companies now develop proprietary and open source SQL-compliant database systems.
In version 9.0 (2007), FileMaker introduced its first support for a SQL feature with the ability to create
live connections to external ODBC data sources (Chapter 7). FileMaker version 12.0 (2012) introduced
the ExecuteSQL function, adding the ability to perform SQL queries against FileMaker tables from any
calculation formula within a FileMaker database.
A SQL Query is a text-based statement used to instruct a database to perform an action. The most
frequently used type of query and the only one supported by the ExecuteSQL function in FileMaker is the
SELECT query, which contains data retrieval instructions for a desired result set.
Experienced SQL programmers will appreciate the back-end functionality that this command adds
to FileMaker but may find the function’s limitation to the SELECT command constraining. Newcomers to
database programming will find the function a little intimidating and divergent from FileMaker’s more
intuitive methods of data access. However, strictly from a FileMaker perspective, ExecuteSQL is like a miracle
opening a new realm of possibility. The benefits of this function are immeasurable.
In FileMaker version 16, the ExecuteSQL function is matured. It allows a search, sort, and summarization
of data to be performed directly from a calculation formula in a completely context-independent manner. It
can perform a search in any table occurrence, including those that have no layout representation, and can
even form temporary relationships dynamically. The functions it makes possible would otherwise require
the creation of a multi-line script and extra table occurrences, relationships, and layouts to establish the
necessary context to achieve the same result. Using this command, it is possible to severely limit the number
of relationships required for data retrieval.
You don’t need to learn SQL or use this command to create databases with FileMaker since the function
is intended as a complement rather than a replacement to the more intuitive features available. However,
once you realize what this function can do and how many resources it makes obsolete, you will want to use it
everywhere it proves practical.
In this chapter, we will define and discuss the process of using the ExecuteSQL function, with topics
such as:
• Defining the ExecuteSQL function
• Creating SQL queries
• Accessing the database schema
■■Tip To experiment with the ExecuteSQL function, be sure to enter some test data into the database. To
prepare the Learn FileMaker database for use with the examples in this chapter, import the us-500.csv
download (Chapter 5) into the Contact table, matching up the name and address fields that we have already
created.
478
Chapter 26 ■ Introducing ExecuteSQL
2
1 3
Contact
Figure 26-1. An illustration of the basic functioning of the ExecuteSQL function, which specifies the data to be
retrieved and optional delimiters to be inserted into that data
479
Chapter 26 ■ Introducing ExecuteSQL
This example shows a formula pattern for requesting the same information using an alternative
fieldSeparator:
This example shows the formula pattern of a request using both an alternative fieldSeparator and
rowSeparator:
480
Chapter 26 ■ Introducing ExecuteSQL
The <what> is the name of one or more fields that should be selected and the <where> is the name of the
table occurrence from which to extract them. Therefore, the pattern above can be formally expressed as the
following formula:
For example, this statement would return the contents of a field named Name from every record in a
table occurrence named Contact:
The above formula defines a SELECT statement requesting all records without further processing.
In addition to this basic requirement, the statement can include many optional clauses that expand the
functionality of the query and offer refinement of and manipulation to the results. The SELECT command
makes available features such as:
• SELECT — Request one or more fields from one or more tables.
• SELECT DISTINCT — Eliminate duplicates from the result.
• JOIN — Create temporary relationships.
• WHERE — Find sets of records matching specific criteria.
• AS — Create dynamic aliases of tables and fields to shorten the length of clauses.
The full formula, including every optional clause except aliasing, is:
481
Chapter 26 ■ Introducing ExecuteSQL
Each of these operational clauses are woven into a text string with other combinations of literals,
keywords, table occurrences, and field names to form a SELECT SQL query, which can be passed as the first
parameter to the ExecuteSQL function.
Formatting Requirements
There are a few formatting requirements to keep in mind when writing SELECT statements for the
ExecuteSQL function. These include:
• Command and Object Names — The names of tables, fields, and even statement
commands within a query are not case sensitive. For example, using either select
or SELECT will work the same. However, using capitalization for all commands and
operators can help to differentiate them from the value of specific tables, fields, and
other variable information in the query. The examples in this chapter will adhere to
that approach.
• Criteria — Literal criteria, such as that used within a JOIN, WHERE, and HAVING clause,
is case sensitive and will fail to locate matching values of a different case. Also, all
textual criteria must be enclosed in single quotations.
482
Chapter 26 ■ Introducing ExecuteSQL
• Name Separators — When listing multiple tables and fields, always use a comma-
space delimiter between them.
• Quotations — Table and field names don’t need to be enclosed in double quotations
unless they contain spaces. Table names that begin with non-alphabetic characters
must be enclosed in double quotations even when they don’t contain spaces.
The statement must always begin with the word SELECT since that is the only primary function currently
supported by FileMaker. After this the statement must indicate which fields to select and FROM which table.
In this case, the asterisk informs FileMaker to select all fields. The <Table> placeholder is replaced with the
name of an actual table occurrence whose base table the function should access. Change this portion of the
formula to Contact and the following SELECT statement we fetch every field from the Contact table will read
as follows:
This SELECT statement becomes the first parameter of the ExecuteSQL statement:
Open the Learn FileMaker database and enter this as the formula for the Example Calculation field.
After confirming that the Calculation result type is of Text, save the formula, and the result displayed in
Figure 26-2 should appear in the field. Each paragraph of the result is a single record that contains a
comma-separated list of field values. Both records and fields are displayed in creation order.
Figure 26-2. An example result of the ExecuteSQL function when requesting every field from every record of
the Contact table
483
Chapter 26 ■ Introducing ExecuteSQL
■■Caution Any table names that include spaces or begins with non-alpha characters must be enclosed in
double quotations to work correctly in an SQL query. Since the Select statement is contained in quotes within
the ExecuteSQL, the inner quotations around the table name must be escaped (backslash-quote) as shown in
this example showing a hypothetical table named Expense Data:
■■Caution Like table names, field names that contain spaces or reserved words must be enclosed in double
quotations.
To select the Contact Address City field from the Contact table, write the following formula:
This statement will result in a carriage return-delimited list of city names from every record in the table,
partially shown in Figure 26-3. Notice that the list includes the field value for every record, so it will include
many duplicates like those highlighted.
484
Chapter 26 ■ Introducing ExecuteSQL
Figure 26-3. The list of city names selected from the Contact table
To select the Contact Address City and Contact Address State fields from the Contact table, write
the following formula:
ExecuteSQL (
"SELECT \"Contact Address City\", \"Contact Address State\" FROM Contact" ;
"" ; "" )
485
Chapter 26 ■ Introducing ExecuteSQL
The result of this statement will be a comma-delimited list of city and state names, partially shown in
Figure 26-4.
Figure 26-4. The list of cities and states selected from the Contact table
Let ( [
reference = GetFieldName ( Contact::Contact Name First ) ;
reference = Substitute ( reference ; "::" ; "¶" ) ;
table.name = GetValue ( reference ; 1 ) ;
field.name = Quote ( GetValue ( reference ; 2 ) )
] ;
ExecuteSQL ("SELECT " & field.name & " FROM " & table.name ; "" ; "" )
)
486
Chapter 26 ■ Introducing ExecuteSQL
The Let statement converts the dynamic field reference into a text string and places it into the
reference variable. The Substitute function is then used to replace the two colons with a paragraph return,
placing the following text value into the reference variable:
Contact
Contact Name First
Finally, each value is extracted and placed into the table.name and field.name variables respectively.
From there, they can be used to construct the SELECT statement that is placed into an ExecuteSQL function.
This extra effort ensures that any changes to the table or field name will automatically be updated and
the query will continue to function as expected.
The following formula will generate a list of alphabetically sorted, unique values from the Contact
Address City field of the Contact table:
ExecuteSQL ( "SELECT DISTINCT \"Contact Address City\" FROM Contact" ; "" ; "" )
The uniqueness of the list is based on the entire record value of the result, not individual fields within it.
For example, when selecting only the city, the results will include only one entry for San Jose. However, if
multiple fields are selected, like the street address and city, as shown in the example below, the results will
include multiple entries for San Jose since the rest of the record/row includes other values.
ExecuteSQL (
"SELECT DISTINCT \"Contact Address Street\", \"Contact Address City\" FROM Contact"
; "" ; "" )
Since 123 First Street,San Jose is not equal to 555 Selma Ave,San Jose, both will appear in the
result.
487
Chapter 26 ■ Introducing ExecuteSQL
ExecuteSQL ( "
SELECT <field>
FROM <table>
JOIN <table> ON <formula>
WHERE <formula>
ORDER BY <field>
" ; "" ; "" )
In the formula above, a carriage return is used to separate the actual query from the enclosing
ExecuteSQL statement. Also, a combination of a carriage return and tab is used to separate each clause of the
statement onto its own line, where it is indented to stand out from the enclosing statement.
When multiple fields, find conditions, or other components are used, those can be pushed onto their
own line, further indented for additional clarity as shown here:
ExecuteSQL ( "
SELECT
<field1>,
<field2>,
<field3>
FROM <table>
JOIN <table> ON <formula>
WHERE
<condition1> and
<condition2> and
<condition3>
ORDER BY
<field1>,
<field2>
" ; "" ; "" )
Let ( [
s.Fields = "SELECT <Fields>" ;
s.Table = "FROM <Table> " ;
s.Join = "JOIN <table> ON <formula> " ;
s.Where = "WHERE <formula> " ;
s.Group = "GROUP BY <fields> " ;
488
Chapter 26 ■ Introducing ExecuteSQL
SQL = s.Fields & s.Table & s.Join & s.Where & s.Group
] ;
ExecuteSQL ( SQL ; "" ; "" )
)
For example, to create an alias named c for the Contact table, the FROM clause would appear like this:
FROM Contact AS c
Once the alias c is established, it can be used as a prefix on any field name, in any clause, to identify the
table to which a field belongs. While aliases are not required when selecting fields from a single table, this
example illustrates that it is possible.
■■Note Although the AS clause establishes the alias at the end, it can be used anywhere within the statement.
Again, in such a simple statement, using an alias is unnecessary as illustrated with these three examples
that all generate the exact same result:
When a field with spaces in its name is enclosed in double quotations, the alias prefix should precede
the name, outside of the quotes, as shown here:
489
Chapter 26 ■ Introducing ExecuteSQL
■■Note Literals are also used in clauses that include formulas such as WHERE and JOIN, which are discussed
later in this chapter.
This example demonstrates a literal value inserted into the field results as a field label:
ExecuteSQL ( "
SELECT
'Name: ',
\"Contact Name First\",
\"Contact Name Last\"
FROM Contact"
; " " ; "" )
By placing a literal 'Name:' with the field names and using a fieldDelimiter of a space in the second
parameter of the ExecuteSQL function, this example will return a list of names with a preceding label:
Concatenating Results
Concatenation is the action of linking things together in a chain or series and is possible within SQL queries.
Instead of receiving a raw comma-delimited set of field values and then parsing and manipulating that
information with other formulas or scripts, concatenation allows pre-processing of field values into more
useful results directly within a query statement.
Concatenation of text values is achieved using either the + or || operators x. However, the latter
has been reportedly more reliable and may be less likely to be confused with the same operator used in
mathematical calculations. The code below shows an example of concatenation of a contact’s first and last
names into a single string, with a literal space inserted between them. This is achieved by replacing the
comma-space between the fields with a space, double-bar, space, single quote, space, single quote,
space, double-bar, space, as shown here:
ExecuteSQL ( "
SELECT \"Contact Name First\" || ' ' || \"Contact Name Last\"
FROM Contact
" ; "" ; "" )
Using the alternative plus-sign delimiter, the SELECT line of the above example, would be:
In both examples, each record of the result should contain the first and last name of a contact with
a space between them. For example, with concatenation, the examples would return a result of Art
Venere instead of Art,Venere, without it. While the same result could have been achieved using the
fieldDelimiter parameter, by concatenating the fields directly in the statement, that delimiter remains
available for use between other fields that may be included in the query but not concatenated within the
same statement.
490
Chapter 26 ■ Introducing ExecuteSQL
This example shows how to return a contact's full name and entire mailing address as a continuous
concatenated string:
ExecuteSQL ( "
SELECT
\"Contact Name First\" + ' ' +
\"Contact Name Last\" + ' ' +
\"Contact Address Street\" + ' ' +
\"Contact Address City\" + ', ' +
\"Contact Address State\" + ' ' +
\"Contact Address Zip\"
FROM Contact
" ; "" ; "" )
The <formula> portion of the clause must contain one or more expressions that specify the criteria used
to qualify records that should be returned. These will typically include a field, operator, and either a literal
value or another field.
■■Note Just like when using fields in the select list, fields in the WHERE clause must be enclosed in double
quotations if they contain spaces. Also, literal textual values must always be enclosed in single quotations.
The following shows an example of a SELECT statement with this expression in a WHERE clause to extract
the first and last name of every contact with an address in California from a Contact table:
SELECT
"Contact Name First",
"Contact Name Last"
FROM Contact
WHERE "Contact Address State" = 'CA'
491
Chapter 26 ■ Introducing ExecuteSQL
WHERE "Contact Address City" = 'Milford' AND "Contact Address State" = 'PA'
Similarly, to find contacts from two different states, for example, from Pennsylvania or Ohio, you would
use an OR operator, as shown in this example:
For example, to return a list of every contact’s last name sorted by state:
SELECT "Contact Name Last" FROM Contact ORDER BY "Contact Address State"
Combining the ORDER BY with a WHERE clause, this example will return the last name of every contact
living in a city named “Milford” sorted by state:
492
Chapter 26 ■ Introducing ExecuteSQL
To connect the Contact and Company tables in the Learn FileMaker database, assign them an alias of
con and com respectively and add a JOIN clause. To retrieve the Contact Name First field and the related
Company Name field, use the following query:
SELECT
con."Contact Name First",
com."Company Name"
FROM Contact AS con
JOIN Company AS com ON
con."Contact Company ID" = com."Record ID"
The example above declares aliases in the SELECT and JOIN statements and then uses them throughout
the statement.
■■Tip The JOIN clause can also be used to create self-joins, which is a table related to itself.
The clause acts much like a FileMaker-native summary field when placed in a sub-summary part on a
layout displaying records sorted by the appropriate field. It generates a summarization of data based on a
sort/grouping field.
For example, if the Contact table had a field called Invoices that contained a total of a customer’s
invoices, the following code without a GROUP BY clause will return a list of each contact’s State and their
Invoice amount:
By contrast, using the Sum function on the Invoices field and adding a GROUP BY clause to group by
state, this example will return a summary of invoices by state:
493
Chapter 26 ■ Introducing ExecuteSQL
Notice that the ORDER BY clause is removed from the example above since the GROUP BY clause will
automatically sort the results by the grouping field(s).
The clause acts like a WHERE clause but for grouped results. Using the previous example, we can add a
HAVING clause to only include states where the summary of Invoices is greater than a certain dollar amount,
as shown here:
SELECT State, Sum ( Invoices ) FROM Contact GROUP BY State HAVING Sum ( Invoices ) > 1500
-- Result =
AK,1750
CA,2500
Etc.
In the results, the summarized entry for AZ has been removed because the summary of 1250 was under
the threshold of 1500 that is specified in the HAVING clause.
By default, the clause will automatically exclude duplicate entries from the merged result. Use UNION
ALL to include all results, even duplicates, for example:
SELECT <fields1> FROM <table1> UNION ALL SELECT <fields2> FROM <table2>
494
Chapter 26 ■ Introducing ExecuteSQL
This example will return a list of all the Record ID field values from the Contact table, starting from
record 21:
This example will return the Record ID for the first 10 records:
SELECT <fields> FROM <table> OFFSET n ROWS FETCH FIRST n ROWS ONLY
The OFFSET portion indicates where the desired group starts and the FETCH FIRST portion limits the
number of records accessed from that starting point. This code shows several examples of accessing batches
of records ten at a time:
The first statement will return records 1 through 10. The second statement will return records 11 thru
20, the third will return records 21 thru 30 and so on.
495
Chapter 26 ■ Introducing ExecuteSQL
Selecting FileMaker_Tables
The FileMaker_Tables table contains one record for every table occurrence defined in the relationship
graph with the following fields of information:
• TableName — The name of the table occurrence.
• TableID — FileMaker’s identification number for the table occurrence is unique
within the database.
• BaseTableName — The name of the actual table upon which the table occurrence is based.
• BaseFileName — The name of the file in which the table occurrence’s base table exists.
• ModCount — The number of modifications made to the table.
Each of these fields can be used in a SELECT statement just like a custom field from your tables.
To get all five fields for every table in the database, use the asterisk, as shown here:
To get a list of every table occurrence in the database, specify the TableName field only:
496
Chapter 26 ■ Introducing ExecuteSQL
To limit the results to the actual table names, use SELECT DISTINCT and request the BaseTableNamee:
■■Tip All the clauses and options available in the SELECT statement can be used when accessing the hidden
FileMaker_Tables and FileMaker_Fields tables.
Selecting FileMaker_Fields
The FileMaker_Fields table contains one record for every field defined in the database file with the
following fields of information, all accessible through the ExecuteSQL function:
• TableName — The name of the table occurrence whose base table contains the
field exists.
• FieldName — The name of the field.
• FieldType —The SQL data type of the file.
• FieldID — FileMaker’s identification number for the field is unique within the base
table containing the field.
• FieldClass — The class of the field: Normal, Summary, or Calculated.
• FieldReps — The number of maximum repetitions defined for the field.
• ModCount — The number of modifications made to the table.
Each of these fields can be used in a SELECT statement just like any custom field from your tables.
To get all seven fields for every field in the database, use the asterisk, as shown here:
Since the hidden fields table contains fields based on table occurrences, the results will include duplicates
if there is more than one occurrence for a given base table. A custom script or a recursive custom function like
the one below named Unique_FileMaker_Fields can be used to get a list of the name of every base table and
then retrieve the fields for each, resulting in a clean list of base tables and their fields without any duplicates:
Let ( [
current.table = GetValue ( baseTables ; 1 ) ;
baseTables = RightValues ( baseTables ; ValueCount ( baseTables ) - 1 )
] ;
ExecuteSQL (
"SELECT * FROM FileMaker_Fields WHERE TableName='" & current.table & "'"
; "" ; "" ) &
Case ( baseTables ≠ "" ; Unique_FileMaker_Fields ( baseTables ) )
)
497
Chapter 26 ■ Introducing ExecuteSQL
https://fmhelp.filemaker.com/docs/16/en/fm16_odbc_jdbc_guide.pdf.
https://fmhelp.filemaker.com/docs/16/en/fm16_sql_reference.pdf.
Summary
In this chapter, we introduced the ExecuteSQL function and discussed many features of the SELECT
statement.
498
PART IV
Designing Interfaces
The user interface of a database is composed of one or more layouts with fields and other
objects that allow a user to interact with the underlying data structure. These chapters cover
the basics of constructing user interfaces:
27.
Introducing Layout Mode — Provides a general orientation to
Layout mode.
28.
Getting Started with Layouts — Discusses how to plan, create,
and manage layouts.
29.
Exploring Layout Palettes — Explores the tools available on the
Field Picker, Inspector, and Layout Objects palettes.
30.
Creating Layout Objects — Covers the creation of layout objects.
31.
Manipulating Objects — Discusses the placement and
organization of layout objects.
32.
Using Themes and Styles — Introduces the use of themes and
styles to improve the management of the formatting of layout
objects.
33.
Customizing Menus — Explains how to create custom menus to
take total control over the user interface.
CHAPTER 27
■■Caution Many new tools and concepts about layout mode will be briefly introduced in this chapter and
then explored in more detail in subsequent chapters.
Poorly designed layouts can be a cluttered, visual nightmare that confuses the user, frustrates the
workflow, and causes more problems than they are intended to solve. By contrast, a well-designed
layout can be an artistically expressed robustly featured, efficiently visualized graphical masterpiece that
anticipates a user’s needs and extends powerful, time-saving tools for manipulating and repurposing data in
a convenient and intuitive way.
As you begin working with layouts, remember to keep design in mind.
■■Caution When learning the design tools or working on a proof of concept for a new feature, design can
be temporarily disregarded. Also, the layout examples shown in this book are not created with design in mind,
only functionality presented for demonstration purposes. Don’t assume they are intended as examples of good
design.
502
Chapter 27 ■ Introducing Layout Mode
Figure 27-1. The differences between Browse mode (left) and Layout mode (right), with optional rulers, grids,
guides, and three palettes currently visible
503
Chapter 27 ■ Introducing Layout Mode
1 2 3 4
5 6 7 8 9 13
10 12
11
The toolbar can be divided into the following regions, discussed further in this section:
1.
Navigation controls
2.
New Layout / Report button
3.
Layout tools
4.
Manage Database menu
5.
Layout navigation menu
6.
Layout Settings button
7.
Theme selector
8.
Field Picker toggle button
9.
Screen dimension overlay menu
10.
Layout Inspector palette toggle button
11.
Layout Objects palette toggle button
12.
Formatting Bar toggle button
13.
Exit Layout button
504
Chapter 27 ■ Introducing Layout Mode
Navigation Controls
At the top left of the toolbar are navigation controls that appear and function exactly as they do in Browse
mode with one important difference: they refer to and control layouts rather than records. The total refers to
the total number of layouts that exist in the current file and the number in the text box indicates which layout
is being currently viewed.
To move to a different layout:
• Click the Next or Back arrows.
• Drag the slider to the left or right.
• Type the number of the desired layout in the box above the slider and type the
Enter key.
Layout Tools
Running along the center of the toolbar are a row of Layout Tools, defined in Table 27-1, that are used to
insert layout objects. Some of these can be clicked and dragged downward to place a specific object type
onto the layout. Others are clicked to temporarily change the cursor to either perform a new function or
allow a corresponding object type to be drawn in the layout design area.
Text tool — This tool is used to edit text on a layout or within certain object types such as buttons.
Line tool — This tool is used to draw a line on a layout. Once selected, click and hold the cursor
at a point on the layout and then drag in the direction of the line. When the line has reached the
desired length, release the cursor. To maintain a straight line, hold the Shift key while dragging
horizontally or vertically.
(continued)
505
Chapter 27 ■ Introducing Layout Mode
Table 27-1. (continued)
Icon Tool Description
Shape menu — Click this icon to automatically select the Rectangle shape tool. Click and hold to
reveal the hidden menu with the following three options:
• The Rectangle shape tool is used to draw a rectangle.
• The Rounded Rectangle shape tool is used to draw a rectangle with a default Corner radius
setting of 5%.
• The Oval shape tool is used to draw an ellipse.
To draw a shape maintaining a uniform height and width (a square or circle), hold down the
Option key while dragging out its boundaries.
Field menu — This icon hides a menu that allows the quick insertion of a field onto a layout with
a choice of a Control style. Click and hold on the icon to see the menu.
Button menu — Click this icon to automatically select the Button tool. Click and hold to reveal
the hidden menu with the following two options:
• The Button tool is used to draw a push-style button.
• The Popover Button tool is used to draw a button that, when clicked, will pop open an
attached content area that floats over the layout.
Button Bar tool — This tool is used to draw a segmented bar that can be configured with multiple
attached buttons and/or popover button controls.
Multi-Panel Object menu — Click this icon to automatically select the Tab Control tool. Click
and hold to reveal the hidden menu with the following two options:
• The Tab Control tool is used to draw an object made up of one or more content areas
identified and accessible through tabs.
• The Slide Control tool is used to draw an object made up of one or more content areas
represented by a dot icon at the bottom and accessible by clicking a dot or swiping left or right
on an iOS device.
Portal tool — This tool is used to draw a portal.
Web Viewer tool — This tool is used to draw a web viewer object.
Field tool — This tool is used to drag a new field down onto a layout.
Part tool — This tool is used to drag a new layout part onto a layout.
Format Painter tool — This tool is used to copy formatting from one object to another. With an
object selected, click this tool to copy its formatting into memory. The cursor will change to a
combination selection tool and eyedropper, indicating that the next object you click on will be
reformatted with the settings previously copied.
506
Chapter 27 ■ Introducing Layout Mode
Layout Menu
The lower, non-customizable level of the toolbar starts with the Layout menu on the left. This menu is used
is used to select the layout one wishes to view in the window, which can also be achieved by selecting a
layout from the View > Go To Layout submenu.
Unlike the Browse mode equivalent of this menu, which displays only those layouts that have the
Include in Layouts Menu option selected, in Layout mode this menu displays a list of all layouts in the file.
It includes a Manage Layouts option at the top that will open a Manage Layouts dialog.
Theme Selector
The layout theme selector displays the name of the theme assigned to the layout with a button that will open
a dialog to select a different theme. A layout theme is a collection of stylistic settings that can be applied to
layout parts and objects (Chapter 32).
507
Chapter 27 ■ Introducing Layout Mode
Figure 27-3. The customize toolbar panel attached to the Learn FileMaker database window in Layout mode
508
Chapter 27 ■ Introducing Layout Mode
Once open, items can be added, removed, or rearranged in the same manner as in Browse mode.
Edit Menu
There are many changes to the items in the Edit menu when switching from Browse to Layout mode,
as shown in Figure 27-4.
Figure 27-4. A comparison of the Edit menu in Browse and Layout modes
509
Chapter 27 ■ Introducing Layout Mode
• Revert Changes to Style — This new item will revert the style of the selected
object to the settings prior to pasting style information.
• Duplicate — This new item will create a duplicate of any selected layout objects.
• Export Field Contents — This function is not applicable in Layout mode and is
removed.
View Menu
There are many changes to the items in the View menu when switching from Browse to Layout mode, as
shown in Figure 27-5.
Figure 27-5. A comparison of the View menu in Browse and Layout modes
510
Chapter 27 ■ Introducing Layout Mode
• Ruler / Rulers— The only difference here is one of quantity. In Layout mode, the
menu is pluralized and indicates that it will toggle the visibility of both horizontal
and vertical rulers. In Browse mode, the menu is singular and indicates that it will
toggle the visibility of a horizontal ruler.
• Page Margins — When selected, this menu item transforms the layout's background
by superimposing a graphical representation of the page borders that will be
imposed by the current print settings. Unlike preview mode, which displays record
and field data as a print preview, this feature shows a pseudo-preview overlay while
still in Layout mode. This allows adjustment to design elements from the context of a
printed page.
• Page Breaks— When selected, this menu item superimposes dashed lines on the
background of the layout demarcating page breaks based on the current settings.
When the Page Margins menu is on, these page breaks only show horizontal
divisions between pages within the actual print area. However, when that option is
off, page breaks will run both horizontally and vertically, breaking the entire layout
area into a grid of page-sized portions.
• Grid — This menu item contains a submenu of two choices that control the visibility
and magnetic quality of a grid of major and minor lines, reminiscent of graph paper,
which are intended to assist in more precise alignment of objects:
• Show Grid — This item toggles the visibility of grid lines on layouts in the
current database file.
• Snap to Grid — This item toggles the magnetic property of the grid lines.
When activated, objects dragged on a layout will be pulled to the next available
grid line, helping ease the burden of precision alignment.
• Guides — This menu item contains a submenu of two choices that control the
visibility of guide lines:
• Show Guides — This item toggles the visibility of guide on layouts in the current
database file.
• Snap to Guides — This item toggles the magnetic property of guides. When
activated, objects dragged on a layout will be attracted to the next available
guide, helping ease the burden of precision alignment.
• Dynamic Guides — When selected, this menu item controls the visibility of
automatic guides that are used to help position items with uniform precision. When
an item is dragged around a layout, dynamic guides will appear around and between
objects showing distance and spacing in relation to other objects on the layout.
Developers with experience using modern interface design tools such as Apple’s
Xcode will recognize and appreciate this feature.
■■Note See a more detailed discussion of Rulers, Grids, Guides and Dynamic Guides in Chapter 31,
“Layout Positioning Helpers.”
511
Chapter 27 ■ Introducing Layout Mode
• Show — This submenu contains a list of options for how objects are displayed when
in Layout mode including:
• Instead of fields displaying their name in Layout mode, there is an option to
display Sample Data instead.
• There are options to show Text Boundaries and Field Boundaries, making
visible an object’s dimension regardless of styled appearance.
• The remaining options all toggle the visibility of a small icon called an
object badge superimposed over objects that indicates the use of the feature
corresponding to the menu, each defined in Table 27-2.
Table 27-2. A list of every layout badge that can be superimposed on a layout object to indicate its
use of a feature
Icon Description
The object is formatted as a button.
• Field Picker — This item will toggle the visibility of the Field Picker.
• Inspector — This item will toggle the visibility of the Layout Inspector, which is
used to configure layout objects.
• New Inspector — This item will create a new instance of the Inspector. FileMaker
allows multiple inspectors to be visible at once, each with a different tab selected or
in different places around your computer screen(s).
• Accessibility Inspector — This new item opens a small window into which
allows Title and Help Text to be assigned to a field label.
• Layout Objects — This new item opens the Layout Objects palette for selecting,
layering, and hiding objects.
512
Chapter 27 ■ Introducing Layout Mode
■■Note See a more detailed discussion of the Field Picker, Inspector, and Layout Objects palette in
Chapter 29.
Insert Menu
There are many changes to the items in the Insert menu when switching from Browse to Layout mode, as
shown in Figure 27-6.
Figure 27-6. A comparison of the Insert menu in Browse and Layout modes
The first two sections of the Layout mode version of the Insert menu provide an alternate method of
inserting any type of layout object, essentially mirroring the toolbar icon features.
In the middle are several shortcuts for placing static text directly on a layout in a manner like inserting
the same into a field:
• Picture
• Current Date
• Current Time
• Current User Name
513
Chapter 27 ■ Introducing Layout Mode
Below these are options that provide a shortcut for the insertion of various dynamic placeholder
symbols. These are specially formatted text that is automatically replaced with current values at the time a
layout is rendered in other non-layout modes. These include:
• Date Symbol — This item inserts the text symbol for the display of the current date;
{{CurrentDate}}.
• Time Symbol — This item inserts the text symbol for the current date;
{{CurrentTime}}.
• User Name Symbol — This item inserts the text symbol in the current user’s
computer name; {{UserName}}.
• Page Number Symbol — This item inserts the text symbol for the current page
number when a page is printed or previewed; {{PageNumber}}.
• Record Number Symbol — This item inserts the text symbol for the current record’s
number within the found set; {{RecordNumber}}.
• Other Symbol — This item opens a dialog that allows the selection of any of over a
hundred different symbols, each corresponding to a Get function (Chapter 22).
While the symbols above allow dynamic insertion of numerous standard values, it is also possible to
place a merge field or merge variable into layout text. A merge value is a text string enclosed between a set
of left shift (<<) and right shift (>>) symbols that indicates to FileMaker that it is a placeholder that should
be dynamically replaced with the actual contents of a field or variable when a layout is rendered in a mode
other than Layout.
These features are at the bottom of the Insert menu:
• Merge Field — This item opens a Specify Field dialog and places the selected
local or related field on the layout, formatted as a merge field; <<FieldName>> or
<<TableName::FieldName>>.
• Merge Variable — This item inserts two dollar symbols enclosed in merge brackets
<<$$>> into which you can type the name of a global variable. For example, a global
variable named $$CurrentSeason would be enclosed in symbols like a merge field to
form the string: <<$$CurrentSeason>>.
Once a standard symbol or merge value is present on the layout, it can be manipulated and formatted
like any other text or combined with static text in a single string. Any symbol or merge value will be detected
and replaced with dynamic values when FileMaker renders the layout for Browse, Find, or Preview mode.
■■Note Dynamic placeholder symbols, merge fields, and merge variables are also discussed in Chapter 30,
“Working with Text.”
Format Menu
There are many changes to the items in the Format menu when switching from Browse to Layout mode, as
shown in Figure 27-7. In Layout mode, items in this menu are enabled or disabled depending on the type of
object(s) currently selected on the layout.
514
Chapter 27 ■ Introducing Layout Mode
515
Chapter 27 ■ Introducing Layout Mode
Layouts Menu
The Layouts menu, shown in Figure 27-8, provides access to functions related to managing, designing, and
configuring layouts.
■■Note See a more detailed discussion of creating and deleting layouts in Chapter 28.
516
Chapter 27 ■ Introducing Layout Mode
• Save Layout — Saves any accumulated unsaved layout changes while remaining in
Layout mode.
• Revert Layout — After a confirmation dialog, this item discards any unsaved changes
and reverts the layout to its previously saved state while remaining in Layout mode.
Arrange Menu
The Arrange menu, shown in Figure 27-9, provides access to functions used when moving or layering objects
on layouts, most of which are described in Chapter 31.
• Group — This item groups all the currently selected objects into a single object.
Grouped objects can be selected and moved while remaining in positions relative
to each other. A selection can include groups, which means you can create nested
groups.
• Ungroup — This item ungroups the currently selected object(s), one level back
toward their singular status.
• Lock — This item will lock the selected object(s) positions and settings. The object
can’t be modified or moved until it is unlocked.
• Unlock — This item will unlock the selected object(s) for editing.
• Bring to Front — This item will move the selected object(s) to the top of the stack
of objects in front of any other objects.
• Bring Forward — This item will move the selected object(s) forward one step in the
stack of objects.
• Send to Back — This item will move the selected object(s) to the bottom of the
stack, behind of any other objects.
517
Chapter 27 ■ Introducing Layout Mode
• Send Backward — This item will move the selected object(s) backward one step in
the stack of objects.
• Rotate — This item will rotate the selected object(s) 90 degrees (clockwise).
• Align — This submenu contains commands that align selected objects horizontally
(Left Edges, Center, Right Edges) or vertically (Top Edges, Middle, Bottom Edges).
• Distribute — This submenu contains commands to evenly distribute selected
objects Horizontally or Vertically.
• Resize To — This submenu contains commands to resize selected objects relative to
the smallest or largest of the group by height, width, or both.
Summary
In this chapter, we introduced Layout mode and identified changes to the window, toolbar, and menu.
518
CHAPTER 28
A new database file is created with a single empty layout representing the default table. As a developer, you
are responsible to define the fields and relationships that make up the data structure. Similarly, you are
responsible for the user interface and must add, rename, design, delete, and organize layouts.
In this chapter, we explore the following subjects:
• Planning layouts
• Working with layout parts
• Adding layouts
• Deleting layouts
• Using the manage layouts dialog
• Optimizing layout performance
Planning Layouts
Before building layouts, take a moment to review the classification methods available for categorizing
layouts and to sketch out a layout navigation flow.
However, two areas of focus in the application development interface use terms that can be easily blurred
into a mistaken assumption that there are official layout types:
• Content view
• Layout creation options
Let’s take a moment to clarify these before focusing on the more important functional categories of
layouts that are common to most databases.
Figure 28-1. The different perspectives of the available content view options
Form and List views are similar in that they both always display the layout as designed and are different
only in how many records are visible at a time.
List and Table views are similar in that they both display a list of the records in the found set but
different in that one displays the layout as designed while the other imposes a predetermined display format
that supersedes the layout design.
The similarly in terminology here, especially for List and Form, blur the line between function and
content view and are easily confused or informally construed to be the layout’s type. However, from the
perspective of the classification of the layout instead of how it is viewed, it’s generally best to ignore the
content view options.
The only relevant consideration is that a layout’s design or function will usually imply a specific view
and might influence which views you enable for user selection. If a layout is structured to serve the function
of displaying a list of records a user can view it as a single record Form instead, if that view option is enabled.
Similarly, if a layout is structured to serve the function of displaying a single record at a time as a form, a
user can view it as a List instead, if that view option is enabled. The layout design doesn’t change when a
different view is selected, only its appearance as viewed in the window.
520
Chapter 28 ■ Getting Started with Layouts
Figure 28-2. An organization of common layout types into a hierarchy based on various factors
This chart has a couple of levels of hierarchy at the top to help illustrate some broader categories for
a layout’s purpose and usage. These aren’t critically important but help to establish some of the different
wider groupings into which a layout may fall.
521
Chapter 28 ■ Getting Started with Layouts
For example, a layout can typically serve one of two different fundamental purposes. It may be used
as either:
• A user interface access point where humans view and manage data. These may be
designed for a specific type of device, as needed.
• A hidden staging context point that provides access for developers to test and
troubleshoot or for scripts to perform automatic functions from a specific context.
Finally, a layout is usually designed to display either a single record form or a multi-record list.
As mentioned earlier, these may imply a view choice but they aren’t necessarily synonymous.
522
Chapter 28 ■ Getting Started with Layouts
■■Tip Most references to a layout type in this book will be focused on the function of the layout unless
specifically referring to a FileMaker feature or settings in a dialog.
The common layout types described above can be combined with other specific interface needs
demanded by a project to compile a custom list of layout requirements.
523
Chapter 28 ■ Getting Started with Layouts
Menu Sandbox
Other:
Reports
Additional Tables Dialogs
Developer
Figure 28-3. A rough sketch of a rather simple hypothetical layout flow with optional placeholders denoting
areas for expansion
In this diagram, we have a rough representation of the Learn FileMaker database with an added
menu layout and placeholders for hypothetical other layouts. Remember, the navigational arrows are only
illustrating hypothetical connections that may be required. These may vary in complexity depending on the
number of tables, the style of the navigational controls you develop, and other factors.
524
Chapter 28 ■ Getting Started with Layouts
Figure 28-4. A typical layout with minimum default layout parts, highlighting various components
525
Chapter 28 ■ Getting Started with Layouts
526
Chapter 28 ■ Getting Started with Layouts
• Footer — Like a Header, this part type will appear at the bottom of every screen or
page, except for the first instance if a Title Footer is present.
• Title Footer — Like a Title Header, this part type will appear at the bottom of the
first screen or page, replacing the first instance of a Footer if one is present.
• Bottom Navigation — Like Top Navigation, this part type is intended to contain
navigation buttons and other controls. It will only appear onscreen at the bottom of
the layout but will not print or appear in preview mode.
Managing Parts
Beyond the default parts automatically added during the layout creation process, parts can be added,
deleted, and reordered as needed to create a simpler or more complex layout. This can be done directly in
the window in Layout mode or through the Part Setup dialog.
527
Chapter 28 ■ Getting Started with Layouts
■■Tip Adding a part to a layout with this method is somewhat imprecise and always changes the size of
an existing part. Instead, use the Part Setup dialog described later in this chapter to add new parts without
adversely affecting existing ones.
Editing a Part
When creating a new part, the Part Definition dialog, shown in Figure 28-6, is automatically opened.
An existing part can be edited by opening this dialog using any of the following methods:
• Double-clicking on the part label.
• Selecting a part label and then the Layout > Part Setup menu.
• Choosing Part Definition from the contextual menu when clicking on a part label.
1 2
3
4
5
6
7
8
Figure 28-6. The Part Definition dialog in which parts are configured
528
Chapter 28 ■ Getting Started with Layouts
2.
Field Selection — This combination of a pop-up menu of table occurrences
and corresponding field list allows the selection of a field that will be used as
the break field when defining a Sub-Summary part. For all other part types, these
controls are disabled.
3.
Page break before each occurrence — Enable this check box to insert a page
break before a Trailing Grand Summary, Body or Sub-Summary.
4.
Page break after every X occurrence — Enable this check box to specify
the insertion of a page break after the part has been displayed a specified
number of times. This makes it possible to limit the number of times a Body or a
Sub-Summary part can be repeated on a single page.
5.
Restart page numbers after each occurrence — Enable this check box to
cause FileMaker’s page numbering to restart after each occurrence of the part.
This can be used with a Title Header to effectively create a title page that is not
included in the numbering sequence or with a Sub-Summary to create separately
numbered sections.
6.
Allow part to break across page boundaries — FileMaker will not
automatically split a part across a page boundary unless the contents of the part
won’t fit on a single page. Instead it will leave blank space at the bottom of the
current page and start the part on the next page. However, enabling this check
box will force the part to be split across a page break. The adjacent Discard
remainder of part before new page check box will truncate any remaining
content for the part instead of displaying it on the next page, effectively only
displaying the portion of the part that fits in the available space at the bottom of
the page.
7.
Use alternate row state — Enable this check box to cause Body parts to be
alternatively styled to visually provide a clear delineation between one record
and the next.
8.
Use active row state — Enable this check box to cause the Body part of the
currently selected record to be differently styled to visually provide an indication
of that state. This formatting option only affects onscreen display of records and
does not appear in preview mode or when a layout is printed.
Deleting a Part
To delete a part, select the part label and type Delete.
529
Chapter 28 ■ Getting Started with Layouts
Figure 28-7. The Part Setup dialog allows for more precise control over the part stack
The Part Setup dialog displays a list of all the parts defined on the current layout and makes available
the following actions:
• Reorder — Drag and drop existing parts to reorder them within the list if they are not
locked into a position within the hierarchical stack because of their type restrictions,
indicated with a lock icon next to the part name.
• Add — To create parts with more precision click the Create button. This will open
the Part Definition dialog allowing configuration of the part type immediately.
The new part will be inserted into the layout between existing parts without resizing
or adversely affecting them.
• Edit — To change a part’s type or settings, select it in the list and click the Change
button. This opens the Part Definition dialog for the selection.
• Delete — To delete a part from the list and the layout, select it and click the Delete button.
Adding Layouts
There are two different ways to add layouts to a database file:
• Creating a new layout
• Duplicating an existing layout
530
Chapter 28 ■ Getting Started with Layouts
Each of these will open the New Layout/Report dialog, shown in Figure 28-8. This dialog is a setup
assistant, like a “wizard” in other systems, which guides you through the settings for the new layout. The
options allow configuration of default settings based on the type of device for which the layout is intended
or the function it will serve. However, any of these settings can be modified later and some developers just
choose Computer and click Finish to bypass the setup assistant and quickly create a new empty layout.
1 2
5 6 7 8
531
Chapter 28 ■ Getting Started with Layouts
5.
Touch Device Orientation — If designing the new layout for a touch device,
click on the portrait or landscape icon to indicate the desired orientation for the
layout.
6.
Custom Device Measurements — This area will display a width and height field
for entering layout dimensions when designing for a custom touch device.
7.
Cancel — Click this button to close the dialog without creating a new layout.
8.
Finish — Clicking this button will continue the new layout configuration
process. Certain layout types will open additional dialogs prior to the creation of
the new layout.
Icon Description
A form layout is generally used to view one record or find request at a time.
They are so named since they resemble a paper form and are the primary
layout format into which data is entered.
A list view is used to display a list of multiple records in a found set. These are
used to quickly scroll through records, sort them, compare values, and locate
a desired record to which edits will be made after navigating to a form view.
A table view is a kind of dynamic list view that displays records and fields
in a format resembling a spreadsheet. Each record is a row and each field
is a column. The user can rearrange and resize columns by dragging their
headings or sort the records by clicking on a heading. New fields (columns)
and new records (rows) can be created intuitively. Also, a layout actions
pop-up menu is hidden within each field’s heading and provides quick
access to various features including sorting, summarization, field control,
and view control. Table views aren’t high on design and customized
functionality but are a considerably more user flexible than plain lists and
provide, in default functionality, a more familiar environment for those used
to working with spreadsheets.
(continued)
532
Chapter 28 ■ Getting Started with Layouts
Table 28-1. (continued)
Icon Description
A report view is a type of list view that is optimized for either viewing or
printing summarized lists of data. Reports are similar to list views but
generally have more complex grand and sub-summaries of data based on a
sort order.
A label view is a type of list or report view that is optimized for printing
directly onto labels. These can be automatically created vertically or
horizontally and sized to one of a list of preconfigured Avery or Dymo label
formats, or developer-entered custom measurements.
An envelope view is type of list or report view that is optimized for printing
directly onto envelopes.
533
Chapter 28 ■ Getting Started with Layouts
Figure 28-9. The Modify Table View and Add Fields dialogs for selecting which fields are options on a
table view
On the top will be an Add Fields dialog, which allows the selection of one or more fields to be included
on the new Table layout’s list of available fields. The other, behind it and accessible when the first one is
closed, is the Modify Table View dialog, which lists the fields already assigned to the layout and allows
fields to be added or removed and activated or deactivated on the layout.
■■Note Any field physically placed on the layout will automatically be assigned and visible in the table. Any
field only assigned through the Modify Table View interface will only be visible if enabled and can be disabled
by users.
534
Chapter 28 ■ Getting Started with Layouts
■■Caution When viewed in Layout mode, a Table view layout will not be displayed as a table, but as an
arrangement of standard layout parts and manually inserted fields and other objects. The table formatting and
features are superimposed when the layout is viewed in Browse mode. This allows a developer to offer users
the option of viewing a layout in either a standard full-design Form or List view or, if they choose, as a Table.
This can be helpful in some cases to allow a user to choose a more familiar or data-centric focus with other
design elements obscured.
Fields in the list can be selected in a continuous sequence by clicking one at the start of the sequence
and one at the end of the sequence while holding down the Shift key. Selecting a non-continuous group
of fields can be accomplished by clicking on individual fields while holding the Command (macOS) or
Windows (Windows) key.
Once finished selecting the desired field(s), click the OK button to close the dialog and save the selected
fields into the available field list of the other dialog. Clicking the Cancel button instead will close the dialog
without adding the select fields to the available field list.
535
Chapter 28 ■ Getting Started with Layouts
Figure 28-10. An illustration of the parts of a hypothetical invoice report summarizing sales by year and then
by month
536
Chapter 28 ■ Getting Started with Layouts
6.
Grand Summary (Trailing) — At the end of the report, after all the Invoice records
and various sub-summaries have been displayed for the entire found set, a trailing
grand summary part will appear. Summary fields placed here will automatically
calculate a grand total of the counts and totals for the entire found set.
The Invoice Count Summary and Invoice Total Summary are the same field in both sub-summaries
and the trailing grand summary. These are summary fields that generate a count of the Invoice Number field
and a total of the Invoice Total fields. Since they are placed within a summary part type, they automatically
summarize the values for the records in the group they subsume.
■■Tip When creating a new report record, most dialogs include a small color coded graphical representation
of the report being built. This allows you to visually understand which part(s) of the layout are being referred to
by the interface controls in the setup assistant.
Figure 28-11. The field definitions for the report layout demonstration to follow
The first four fields are used for data entry to store the date, amount, customer, and number of an
invoice. The two summary fields will be used to display the total count and the total dollar amount of
invoices in the various sub-summary and trailing grand summary parts. The three calculation fields are used
to sort records and display values in summary fields.
To begin creating a new report layout, open the New Layout/Report dialog and follow these steps:
1.
Select the Invoice table.
2.
Enter a Layout Name of “Invoice Report.”
3.
Click on the Computer icon.
4.
Click on the Report icon.
5.
Click the Continue button.
This will begin a sequence of eight steps of the setup assistant for report layouts.
537
Chapter 28 ■ Getting Started with Layouts
Figure 28-12. The first step in the sequence for creating a new report layout is the Include Subtotals and
Grand Totals dialog
Select both options so that the Specify Subtotals dialog (Step 6) and Specify Grand Totals
dialog (Step 7) are included in the configuration process. Click the Next button to continue the layout setup
process.
538
Chapter 28 ■ Getting Started with Layouts
Figure 28-13. The second step in the sequence for creating a new report layout is the Specify Fields dialog
To add fields to the list, select the appropriate table occurrence from the pop-up menu and then use
one of these options:
• Click the Move All button to copy all the available fields over to the layout list.
• Select one or more available fields and click the Move button to copy them over to
layout list.
• Double-click directly on individual available fields to quickly copy them over to the
layout list.
Once added, dragging fields up or down in the list will determine the order in which they are added to
the new report layout.
When the desired fields are selected, click the Next button to continue to the next step.
539
Chapter 28 ■ Getting Started with Layouts
Figure 28-14. The third step in the sequence for creating a new report layout is the Organize Records by
Category dialog
Report fields selected in Step 2 are displayed in the left-hand list. These can be added to, removed
from, or enabled in the Report categories list as follows:
• To add one or more fields into the Report categories list, double-click directly on
them in the Report fields list or select them and click the Move button.
• To remove one field from the Report categories list, double-click on it in list or
select it and click the Clear button.
• To remove all fields from the Report categories list, click the Clear All button.
Once in the list, a field will be included as a summarizing category for groups of sorted records. Enable
the adjacent check box to include a field in both the sub-summary layout part and the body of the report.
In our invoice report example, the Invoice Year and Invoice Month fields are both added as categories
because these will be used to summarize groups of Invoice records.
Once the desired options are selected, click the Next button to continue to the next step.
540
Chapter 28 ■ Getting Started with Layouts
Step 4 — Sort
Next in the sequence is the Sort dialog, shown in Figure 28-15, in which you can specify a sort order from
the list of fields added to the report layout. This dialog contains a typical sort interface (Chapter 4, “Sorting
Records in the Found Set”).
Figure 28-15. The fourth step in the sequence for creating a new report layout is the Sort dialog
The Report fields list on the left contains a list of every field added to the report. The Sort order list
on the right contains a list specifying how the records will be sorted when the report is generated. Any fields
added as Report categories in Step 3, will automatically appear in the sort list and be locked at the top of
the sort order, as they are required to establish the summarized groups.
One or more fields from the Report fields list can be added to the Sort order list, each with the
ability to be sorted in Ascending order, Descending order, or in a Custom order based on value list.
There is an option to Reorder based on a selected summary field. Sort fields will be used in several
forthcoming steps.
In our invoice report example, the Invoice Year and Invoice Month fields are both added as categories
because these will be used to summarize groups of Invoice records. They must be placed in the same order
as their corresponding sub-summary parts on the layout: year first, month second.
Once the desired options are selected, click the Next button to continue to the next step.
541
Chapter 28 ■ Getting Started with Layouts
Figure 28-16. The fifth step in the sequence for creating a new report layout is the Specify Subtotals dialog
Across the top, a summary field can be selected for inclusion on the report by clicking the Specify
button. Next, a field can be selected from the Category to summarize by pop-up menu, which lists all
the fields added as report categories in Step 3. The Subtotal placement pop-up menu specifies where the
subtotal will appear in relation to the group of records that it is summarizing, with the following choices:
• Above record group
• Below record group
• Above and below
Once these choices are made along the top of the dialog, click Add Subtotal to insert them into the list
below. Multiple summaries can be added to the list to build up a more robust report with additional levels of
summarized hierarchy. To remove one of the Subtotals from the list, select it and click the Remove Subtotal
button or type the Delete key.
In our invoice report example, the Invoice Count Summary and Invoice Amount Summary fields are
both added as subtotals that will appear below the record group, summarized by both Invoice Month and
Invoice Year so that they appear in both sub-summaries.
Once the desired options are selected, click the Next button to continue to the next step.
542
Chapter 28 ■ Getting Started with Layouts
Figure 28-17. The sixth in the sequence for creating a new report layout is the Specify Grand Totals dialog
A summary field can be selected and added to the list of grand totals with the Grand total placement
pop-up allowing a choice of a location for the grand total relative to the entire report, with the following
options:
• Beginning of report
• End of report
• Beginning and end
Once these choices are made along the top of the dialog, clicking Add Grand Total will insert them into
the list below. Multiple summaries can be added to the list to create a more robust report. To remove a Grand
Total from the list, select it and click the Remove Grand Total button or type the Delete key.
In our invoice report example, the Invoice Count Summary and Invoice Amount Summary fields are
both added as grand totals that should appear at the end of the report.
Once the desired options are selected, click the Next button to continue to the next step.
543
Chapter 28 ■ Getting Started with Layouts
Figure 28-18. The seventh step in the sequence for creating a new report layout is the Header and Footer
Information dialog
The pop-up menus are the same for all six options and include the following values:
• None — Nothing will be added to this region on the new layout.
• Page Number — This choice will place the {{PageNumber}} placeholder on the layout
in the desired position. This symbol will be dynamically replaced with the current
page number when printing the report or viewing in Preview mode.
• Current Date — This choice will place the {{CurrentDate}} placeholder on the
layout in the desired position. This symbol will be dynamically replaced with the
current date when printing the report or viewing in Preview mode.
• Layout Name — This choice oddly places a literal text string containing the layout
name on the layout in the desired position instead of the dynamically updating
{{LayoutName}} placeholder.
• Large Custom Text — This choice displays a Custom Text dialog, shown in
Figure 28-19, into which any custom text string can be entered, which will be added
to the layout in the desired position in a large font size.
544
Chapter 28 ■ Getting Started with Layouts
Figure 28-19. The Custom Text dialog for specifying literal text to add to the newly created layout
• Small Custom Text — This choice displays a Custom Text dialog, into which any
custom text string can be entered, which will be added to the layout in the desired
position in a small font size.
• Logo — This choice displays an Insert Picture file selection dialog, which allows
the selection of a picture file, which will be added to the layout in the desired
position.
Once the desired options are selected, click the Next button to continue to the next step.
Figure 28-20. The eighth step in the sequence for creating a new report layout is the Create a Script for
this Report dialog
545
Chapter 28 ■ Getting Started with Layouts
With the Do not create a script radio button selected, the setup process will not create a script for
the report. The user must perform a find, navigate to the report, sort records, and print or preview the report
manually, unless a developer manually creates a script to do so.
Clicking the Create a Script radio button will prompt the report setup process to automatically create
a script. Enter a name for the new script in the adjacent Script name text area. The name will default to the
same name as the layout being created, but can be modified to be more descriptive if desired. The script will
include up to three steps automatically configured depending on other options in this process:
• Enter Browse Mode
• Go to Layout
• Sort Records
The Sort Records script step will only be included if sort fields were specified in Step 4. Selecting
the Run script automatically check box, will automatically assign an OnLayoutEnter Script Trigger
(Chapter 37) that will be configured to run the new script whenever a user or another script navigates to the
layout being created.
Once the desired options are selected, click the Finish button to continue to complete the creation of
the new layout.
Figure 28-21. The layout automatically created based on the options selected in the setup assistant dialogs
546
Chapter 28 ■ Getting Started with Layouts
547
Chapter 28 ■ Getting Started with Layouts
This dialog allows the selection and insertion of merge field tags into the Label contents text area.
Mentioned Chapter 27 and 30, a merge field is the name of a field encased in a set of left-shift (<<) and
right-shift (>>) symbols that, when present on a layout, will be rendered in non-Layout modes as actual field
contents for the current record. Merge fields can be intermixed with any other text contents such as static
values and paragraph carriage returns to create a formula for generating multi- line label content.
To add a field to the Label contents area, either double-click it in the list or select it in the list and click
the Add Field button. You can selectively edit the Label contents by highlighting some or all the text and
typing the Delete key. To completely clear all data entered so far, click the Clear All button.
548
Chapter 28 ■ Getting Started with Layouts
This dialog allows the selection and insertion of merge field tags and other text in the exact same
manner as the Specify Label Contents dialog.
549
Chapter 28 ■ Getting Started with Layouts
Configuring Layouts
Once a layout is created, there are many layout configuration settings that customize its features and behavior.
General
The General tab of the Layout Setup dialog, shown in Figure 28-25, contains general settings of the current
layout.
1
2
3
4
5
6
7
8
Figure 28-25. The General tab of the Layout Setup dialog, showing default values for check boxes
550
Chapter 28 ■ Getting Started with Layouts
The controls on the General tab of the Layout Setup dialog include:
1.
Layout Name — This text area contains the name of the layout and can be
modified as needed. Although FileMaker will allow you to create two layouts with
the same name, to avoid confusion, this should be avoided.
2.
Include in layout menus — Check this box to have the layout name appear
in the toolbar Layout pop-up menu and the View > Go to Layout menu when
viewing the database in any non-Layout mode.
3.
Show records from — This pop-up menu contains a list of every table
occurrence in the database. The selected occurrence establishes both the
relational context for the layout and determines which table’s records will be
displayed on the layout when browsing. If the selection is changed for a layout,
the relationship context for any fields will need to be changed.
4.
Save record changes automatically — Check this box to automatically save
changes anytime a user or script commits a record by clicking on the background
away from any field, navigating to a new record or closing the file. If left
unchecked, when performing any of these actions, a dialog will appear asking if
the user wants to save changes, giving them the following options:
• Save — closes the record and saves changes.
• Cancel — returns to edit mode within the record without saving.
• Don't Save — reverts to the previous values in every field that was modified
during the user’s editing session.
5.
Show field frames when record is active — When editing a record, the field
with focus will be styled uniquely according to its layout settings. Checking this
box will cause the borders of every other field on a layout to be displayed with
dotted lines, emphasizing that the record has editing focus.
6.
Delineate fields on current record only — Enabling this check box will
change the way field borders and fills are displayed in Browse mode when
viewing List layouts. When checked, only the current record will display field
border and fill settings. While fields on other records will still draw their content,
they will not display any border or fill settings at all if this box is enabled. Any
empty fields will seem to disappear.
7.
Show current record indicator in list view — When this box is checked,
a small vertical black bar will appear along the left side of the currently selected
record in a list view. This provides a somewhat outdated way of indicating which
record has active focus. The Use active row state check box on the Part
Definition dialog for the Body part provides a preferable modern method of
identification of the current record.
8.
Menu Set — This pop-up menu lists all menu sets defined in the file and an
option to open the Manage Custom Menus dialog (Chapter 33).
9.
Enable Quick Find — This check box allows enabling or disabling of the Quick
Find feature (Chapter 4) for the entire layout. When the feature is enabled
and some fields have had their Quick Find feature turned off in the Layout
Inspector (Chapter 29), clicking the Reset Quick Find button here will return
all fields back to their default setting.
551
Chapter 28 ■ Getting Started with Layouts
Views
The Views tab of the Layout Setup dialog, shown in Figure 28-26, controls which Content Views will be
available to users for the current layout (Chapter 3, “Defining Content Views”).
Figure 28-26. The Views tab of the Layout Setup dialog, showing default values for check boxes
This dialog contains a set of three check boxes that determine which content view types are accessible
to a user through the toolbar and which is the default when a user or script first navigates to a layout.
When the Table view check box is selected, the adjacent Properties button becomes enabled. This
button will open the Table View Properties dialog, shown in Figure 28-27, which provides control over
how a layout appears in Browse mode when viewed in Table view.
552
Chapter 28 ■ Getting Started with Layouts
Figure 28-27. The Views tab of the Layout Setup dialog, showing default values for check boxes
553
Chapter 28 ■ Getting Started with Layouts
The third section of the dialog contains choices that control column headings. The options are:
• Include column headers — Check this box to make column headers visible. When
selected, the two other check boxes become enabled.
• Resizable columns — Check this box to allow a user to resize the columns for their
view.
• Reorderable columns — Check this box to allow a user to reorder the columns by
dragging and dropping them between other columns.
The final section of the dialog controls the height of the record rows. Check the box to activate custom
row height and enable the adjacent controls. Then you can enter a row height number in the text area and
choose a unit of Inches, Centimeters, or Points.
Printing
The Printing tab of the Layout Setup dialog, shown in Figure 28-28, contains controls for print settings
of the layout’s columns and page margins. These should not be confused with settings for print and paper
size that are accessible through the File > Page Setup and File > Print menus. Instead, these focus on
spacing and columns of the layout as a means of controlling the available printable area in which to place
fields and other layout objects.
554
Chapter 28 ■ Getting Started with Layouts
Script Triggers
The Script Triggers tab of the Layout Setup dialog, shown in Figure 28-29, contains controls for triggering
scripts in response to layout events (Chapter 37).
555
Chapter 28 ■ Getting Started with Layouts
Deleting Layouts
Deleting an unused layout can be performed one of two ways:
• Navigate to the layout that you want to delete and select the Layouts > Delete
Layouts menu item.
• Open the Manage Layouts dialog from the Layouts pop-up menu in the toolbar and
use the delete feature there.
FileMaker will present a dialog confirming that you want to delete the layout. Click Delete to
permanently delete the layout from the file or Cancel to stop the deletion process.
5 6 7 8 9
556
Chapter 28 ■ Getting Started with Layouts
The Manage Layouts dialog integrates into one simple dialog the ability to quickly create, view, locate,
edit, duplicate, delete, and open layouts. It also provides the exclusive functions of reordering, adding
separator lines and grouping layouts into folders. The following controls are available on this dialog:
1.
Layout List — The central area contains a list of every layout defined in the file,
showing columns containing the Layout Name, Associated Table, and Assigned
Menu Set. Drag a layout, folder, or separator line up and down the list to reorder,
or drag them inside of folders to re-group.
2.
Quick Filter Popup — This pop-up menu contains a list of every layout folder
defined in the list below. Selecting a folder from the list will filter the list down to
include only those layouts that are contained within that selection. The default
value, and the only option when there are no folders defined, is Show All.
3.
Search Filter — Type text into the search field to filter the list of layouts to only
include those whose name contains the text entered.
4.
Include in layout menus — This check box and the ones above it next to each
individual layout determine if the layout name will appear in the toolbar’s Layout
pop-up menu and the View > Go to Layout menu when in non-Layout modes
such as Browse. Select multiple layouts to enable or disable this check box across
a batch of layouts all at once.
5.
New — This button and the attached pop-up menu create items in the list above.
Click the button or select New Layout/Report from the adjacent menu to start
the process of adding a new layout to the file, described earlier in this chapter.
The menu includes options for creating a separator line and folder in the list,
which are both useful methods for delimiting and organizing layouts.
6.
Edit — Select a layout and click this button to open the Layout Setup dialog.
7.
Duplicate — This button will duplicate the layout(s) selected in the list.
8.
Delete — This button will delete the layout(s) selected in the list after presenting
a confirmation dialog.
9.
Open — This button will open a new window for the selected layout(s).
■■Tip As a database file’s list of layouts grows, it is a good idea to organize them into folders. The easiest
way to do this is by their associated table; however, you may decide to use some other organizational
methodologies based on your own preferences. Folders can be nested hierarchically, so you can create
sub-groupings based on various criteria, such as category of table or making a distinction between layouts
intended for users vs. layouts intended for developers or hidden script access.
557
Chapter 28 ■ Getting Started with Layouts
Summary
In this chapter, we discussed planning an interface and creating, deleting, managing, and optimizing layouts.
558
CHAPTER 29
1 2
3 4
7 8
560
Chapter 29 ■ Exploring Layout Palettes
• Field Options — Choose this item to directly open the Options for Field
dialog for the selected field. This allows fast changes to field definitions.
• Delete Field — Choose this item to permanently delete the field from the table
after a warning dialog.
6.
New Field — This button provides a shortcut for quickly creating a new field in
the selected occurrence’s table. The new field will appear in the list, highlighted
so a name and data type can be quickly assigned before it is dragged onto the
layout.
7.
Field Placement — These two buttons control whether fields dragged onto
a layout will be placed side by side horizontally or stacked one above another
vertically. The former is good for list layouts while the latter is better for form
layouts.
8.
Labels — These four buttons control if a field label is automatically created when a
field is dragged onto the layout and where that label is placed in relation to the field.
■■Caution The palette features that allow editing of a field’s definition or the creation of new fields directly
from the palette will not be available to a user with security access to edit layouts without access to define fields.
■■Tip For fastest access to tools in the Inspector, open it to the maximum height with all the regions
expanded.
It is possible to open multiple instances of the Inspector simultaneously and position them anywhere on the
available display space. This makes it possible to have all four panels open and fully expanded to provide the
fastest access to the variety of settings and tools within.
561
Chapter 29 ■ Exploring Layout Palettes
Position
The Position group, shown in Figure 29-2, contains options for naming and position.
1
2
562
Chapter 29 ■ Exploring Layout Palettes
■■Tip The position and size units will match the current ruler’s settings but can be changed by clicking on
the unit labels, which cycles through the options: centimeters (cm), points (pt), inches (in).
Autosizing
The Autosizing group, shown in Figure 29-3, contains anchoring controls that allow fine control over how an
object moves or grows when a user resizes the window.
The selected object(s) can be anchored to the Left, Top, Right, or Bottom of the layout by toggling the
lock icon on or off on the respective side of the box. A lock on any side means that the distance between that
side of the object and the corresponding edge of the layout will remain fixed as the window is resized while
unlocked means that distance will vary. By using various combinations of locked and unlocked, an object
can be made to either:
• Remain firmly in place at the same size by anchoring it to a corner such as locking
Top and Left.
• Slide to the right or down as the window is resized by anchoring it just to the Bottom
and/or Right sides.
• Grow in width and/or height as the window is resized by anchoring it to two
opposing corners such as Left/Right or Top/Bottom.
• Float in the center of the window as it is resized by anchoring it to no side.
563
Chapter 29 ■ Exploring Layout Palettes
Figure 29-4. The Arrange & Align subgroup of the Position panel of the Inspector
564
Chapter 29 ■ Exploring Layout Palettes
■■Tip Each of these settings are available in the Arrange menu and can therefore be invoked from the
keyboard using a menu’s corresponding Command key combination.
1
2
Figure 29-5. The Sliding & Visibility subgroup of the Position panel of the Inspector
565
Chapter 29 ■ Exploring Layout Palettes
b. Only objects directly above — Choose this option to cause the selected
object(s) in a common horizontal plane to slide up independent of each
other based on the amount the objects above have been resized.
c. Also resize enclosing part — Enable this check box to cause the layout
part enclosing the selected object(s) to also shrink vertically based on the
amount that the selected objects shrink.
3.
Hide when printing — Enable this check box to cause the selected object(s) to
be hidden when printing or previewing the layout.
Grid
The layout grid is a sequence of evenly spaced horizontal and vertical lines overlaid on a layout background
that form a regular grid of minor and major areas, shown in Figure 29-6. This is only visible in Layout mode
and can assist with precision manual placement and spacing of objects.
566
Chapter 29 ■ Exploring Layout Palettes
The Grid group, shown in Figure 29-7, contains settings that allow control over the layout grid for the
entire file.
1 2
3
4
567
Chapter 29 ■ Exploring Layout Palettes
This panel provides information about the layout’s assigned theme and allows saving theme changes.
Depending on the state of the Show All check box, the list displays either a list of all defined styles organized
by object type or only those applicable to the selected object type. The selected object’s assigned style is
always highlighted. Click on a style to apply it to the selected object.
■■Note For more information about Themes and Styles, see Chapter 32.
568
Chapter 29 ■ Exploring Layout Palettes
1
2
3
5
4
Figure 29-9. The Theme and Style subgroup of the Appearance panel of the Inspector
569
Chapter 29 ■ Exploring Layout Palettes
5.
Copy Paste Style — These two sets of buttons allow the selected object type or
state styling to be copied and then pasted onto other objects.
■■Note For more information about an object’s Theme, Style, Type, and State, see Chapter 32.
Graphic
The Graphic group, shown in Figure 29-10, contains controls over the graphical settings of the chosen state
of the selected layout object.
1 2
4
3
6 5
7
Figure 29-10. The Graphic subgroup of the Appearance panel of the Inspector
570
Chapter 29 ■ Exploring Layout Palettes
2.
Fill Settings — This area changes to present settings specific to the selected
Fill Type.
3.
Line Style — This pop-up menu offers a choice of line style for the selected
object’s border: None, Solid, Dashed, and Dotted.
4.
Line Thickness — This combination text area and drop-down menu allows the
entry or selection of a number representing the thickness of the line.
5.
Line Color — Clicking this color well allows the selection of a line color from a
palette.
6.
Line Border — These icon buttons allow toggling of specific line border
settings: All borders, Left, Top, Right, Bottom, and between field repetitions of
repeating fields.
7.
Line Corner Radius — This combination of text area and four icon buttons
allows control over the radius of corners. Enter the percentage of desired
rounding on the object corners into the text area and click buttons that
correspond with the corner(s) to which this will apply.
Advanced Graphic
The Advanced Graphic group, shown in Figure 29-11, contains controls over the advanced graphical settings
of the chosen state of the selected layout object.
1 2
Figure 29-11. The Advanced Graphic subgroup of the Appearance panel of the Inspector
571
Chapter 29 ■ Exploring Layout Palettes
Text
The Text group, shown in Figure 29-12, contains controls of the text and style settings of the chosen state of
the selected layout object.
572
Chapter 29 ■ Exploring Layout Palettes
1
2 4
5
7
6 8
9
573
Chapter 29 ■ Exploring Layout Palettes
7.
Baseline thickness — This combination text area and drop-down menu allows
the entry or selection of a number representing the thickness of the text baseline
for the selection field.
8.
Baseline color — The color well shows the selected color of the text baseline.
Clicking it will open a color palette from which a new color can be assigned.
9.
Baseline offset — This text area contains a number indicating the amount of
offset for the baseline in the selected field.
Paragraph
The Paragraph group, shown in Figure 29-13, contains controls over the paragraph alignment and spacing
settings of an interface state of the selected element.
574
Chapter 29 ■ Exploring Layout Palettes
■■Caution The Line Spacing and Indents settings may compete with those of Padding in the Advanced
Graphic group and may cause confusion if used simultaneously.
575
Chapter 29 ■ Exploring Layout Palettes
Tabs
The Tabs group, shown in Figure 29-14, provides control over the tab settings of a selected object.
Click the + or – buttons to add or remove Tab positions from the list. Click on a Tab position to edit
the measurement and to choose an Alignment and Leader character.
576
Chapter 29 ■ Exploring Layout Palettes
Field
The Field group, shown in Figure 29-15, contains controls over the settings of a selected field.
2
3
577
Chapter 29 ■ Exploring Layout Palettes
4.
Control style — This pop-up menu selects a field control style for the selected
field. The settings in the shaded area below it will vary depending on the style
selected. Control styles include:
• Edit box — The field will be formatted as a standard field area, with or without a
scroll bar, into which a user can click to begin data entry.
• Drop-down list — The field will be formatted as an edit field with an optional
attached value list, allowing a user to select or type a value. Depending on the
settings, the list will appear instantly when the user enters the field or when they
click an optional attached arrow icon. It can be configured to present potential
matching values as they begin typing, which can auto-complete
the entry.
• Pop-up menu — The field will take the form of a pop-up menu, displaying a value
list. Users can choose or paste in a value but can’t type directly into the field.
• Check box set — The field will display value list items as a set of check boxes.
Users can select or unselect values with mouse clicks or by pasting. The field will
contain a carriage-return delimited list of selected or entered values but will only
display on a layout check boxes for those defined in the assigned value list.
• Radio button set — The field will display a value list as a set of radio buttons
allowing a single value selection.
• Drop-down calendar — The date field will be formatted as an edit field into
which the user can type a date with an optional drop-down graphical calendar to
facilitate faster data entry.
• Concealed edit box — The field will be formatted as a standard field area but
all data typed will be obscured will bullets (but not encrypted).
5.
Show repetitions — These settings allow control over which repetitions of a
field are displayed on the layout and the orientation in which they are drawn.
■■Note Control Style options are discussed in more detail in Chapter 30.
578
Chapter 29 ■ Exploring Layout Palettes
Behavior
The Behavior group, shown in Figure 29-16, contains controls that affect various object behaviors on the
layout such as visibility, mode accessibility, and other features.
1
2
5
6
579
Chapter 29 ■ Exploring Layout Palettes
3.
Field entry — These check boxes control when a user can click into the
selected field or not and what happens when they do:
a. Browse mode — Enable this check box to allow a user to click into the field in
Browse mode.
b. Find mode — Enable this check box to allow a user to click into the field in
Find mode.
c. Select entire contents on entry — Enable this check box to
automatically select the entire contents of the field when a user clicks into it.
This is useful when a value is likely to change completely every time a user
makes an edit.
4.
Go to next object using — These check boxes control if the Tab, Return,
and Enter keys jump to the next field or are entered into the field as literal text.
By default, FileMaker uses a Tab keystroke to jump between fields and an Enter
keystroke to commit a record. These check boxes allow that behavior to be
overridden.
5.
Include field for Quick Find — Enable this checkbox to allow the selected
field to be included in Quick Find feature (Chapter 4; Searching with Quick
Find).
6.
Do not apply visual spell checking — Enable this check box to exclude the
selected field from visual spell checking.
7.
Select input method — This pop-up menu contains options for choosing a
specific input language method for the selected field in situations where certain
foreign languages are used such as Japanese.
8.
Touch keyboard type — This pop-up menu contains a choice over which
keyboard type will be available to the user when they click into the selected
field on an iOS device. For layouts that will be used on such devices, this allows
a specific keyboard to be specified that relates to the field’s data type (text,
number) or its intended content (email, phone, URL).
Data Formatting
The Data Formatting group provides control over the formatting overlay based on a selected field’s specific
data type. When a field has editing focus, it will show the information as entered. However, these settings
allow a field to display that information with special formatting characteristics depending on its type.
The top portion of the group, shown in Figure 29-17, displays an icon indicating the data type of the
selected field: decimal, date, time, or container. The Format pop-up menu contains the formatting options
based on that data type and the area beneath this contains controls that vary by the selection made within
this menu.
■■Caution When exporting records, the actual value in the field will be exported instead of the formatting
imposed by these settings, unless the Apply current layout’s data formatting to exported data check box is
selected (Chapter 5).
580
Chapter 29 ■ Exploring Layout Palettes
Figure 29-17. The Data Formatting group of the Data panel of the Inspector
581
Chapter 29 ■ Exploring Layout Palettes
Figure 29-18. The custom date options for the Data Formatting group of the Data panel of the Inspector
The Custom date format presents a flexible modular set of controls that allow the selection of any date
component arranged in any order with any delimiter placed between them and with leading zero options for
day and month numbers. Using these controls, a date entered as 1/15/2017 can be displayed in any number
of different combinations including:
• January 15, 2017
• 01.15.2017
• 01.15.17
• 15 Jan 2017
• Sunday Jan 15, 2017
• 01/15/2017 (Thursday)
582
Chapter 29 ■ Exploring Layout Palettes
583
Chapter 29 ■ Exploring Layout Palettes
Figure 29-19. The container options for the Data Formatting group of the Data panel of the Inspector
584
Chapter 29 ■ Exploring Layout Palettes
2 4
585
Chapter 29 ■ Exploring Layout Palettes
■■Tip For faster selection and editing of objects, open the Layout Objects palette and Inspector(s) side
by side. Select an object from the Layout Objects palette and edit its settings in the Inspector.
Figure 29-21. The contextual menu for an item within the Layout Objects palette
586
Chapter 29 ■ Exploring Layout Palettes
The following commands are available in the contextual menu depending on the type of object selected:
• Hide All Other Objects — This will hide every object on the layout except for the
object(s) currently selected in the Layout Objects palette. This provides a quick way
to isolate the selected object(s) and remove all other distractions from the layout.
• Hide Objects in Front — This will hide every object that is layered in front of the
selected object(s). This allows you to quickly see an object that is hidden behind
other overlapping elements.
• Hide Objects in Front and Back— This will hide every object that is layered in
front of and behind the selected object(s).
• Specify Object Name — By default object names will appear in the palette
generically by object type and/or field name. This command reveals an edit box in
place of this generic name into which you can enter a custom name for the object,
as shown in Figure 29-22. Object names are not widely used in FileMaker but are
important in some instances such as when using the Go to Object script step, which
requires an object name as an identifier rather than a field name or other reference.
587
Chapter 29 ■ Exploring Layout Palettes
■■Tip If you use the Layout Objects palette a lot, assigning object names will greatly improve your efficiency.
Summary
In this chapter, we introduced the Layout mode palettes and explored their various tools and settings.
588
CHAPTER 30
■■Note The illustrations of layout objects pictured in this chapter are designed with default formatting.
However, as indicated previously, FileMaker’s design tools allow for a much more professional design than is
shown in these simple examples.
• Buttons — make script functions accessible to users and hide expandable interface
panels.
• Panels — make efficient use of space by alternating between different groups of
objects within the same space when the user clicks a tab or swipes.
• Portals — can display a limited set of fields in a list of records from another table that
are related to the record being viewed in the window.
• Web Viewers — display web pages, directly from the Internet or dynamically
generated by a formula using information from the database.
• Charts — display data graphically with charts and graphs.
■■Note Some object types have alternative insertion methods that will be noted throughout the chapter.
Configuring an Object
Once a new object instance is inserted on a layout, it will be in a raw state ready to be formatted and
configured. Depending on the type, an object can be configured using some or all of the following methods:
• Double-clicking on most object types will open a configuration dialog, usually
focused on data configuration options rather than formatting or other behavioral
control.
• When an object is selected:
• the Format and Arrange menus contain many styling and positioning options.
• the Inspector contains many configuration options (Chapter 29).
590
Chapter 30 ■ Creating Layout Objects
Table Record
Underlying
Data Structure Field Definition Field Cell
These are all generally referred to as a “field” and, while quite common and acceptable, it might be
confusing to newcomers.
591
Chapter 30 ■ Creating Layout Objects
Elaborating on the material discussed in previous chapters, a field definition for a table is an individual
unit of storage potential that establishes the type of data and certain informational behaviors of that data.
These will be replicated as a field cell for every record created within that table, making an actual unit of
storage that will contain information entered by a user or automatically by a calculation or script process.
■■Tip Remember the spreadsheet metaphor: a field definition is like a column; a record is like a row; and an
instance of a field for a record is like a cell, the intersection of a column at a row.
Because a database user always interacts with the data structure through a layout, the metaphorical
spreadsheet described above is completely hidden from view when thinking of the interface. When
designing a layout, a field object is a graphical element that defines the position, behavior, and appearance
of where and how a referenced field cell should be displayed. In Layout mode, the field object is assigned
a field reference, pointing to a field definition. When viewed in Browse mode, the layout object is rendered
as a field display showing information stored in the field cell for the record currently viewed: formatted and
behaving in accordance with the settings of both the field definition and the layout field object.
It isn’t crucial that one remembers all the terminological details here. However, when thinking or
reading about something referred to as a “field,” just remember that the usage context should be kept in
mind to avoid confusion.
Field Basics
Working with field objects requires a minimum understanding of a few basics.
592
Chapter 30 ■ Creating Layout Objects
593
Chapter 30 ■ Creating Layout Objects
Figure 30-2. Dragging a field onto a layout with the toolbar icon adds a blank field object on the layout before
presenting a Specify Field dialog
Once the object is positioned and the cursor released, the blank field object will be tentatively placed
at the drop point and become the currently selected object. Since a new field object must contain a defined
field reference, a Specify Field dialog, shown in Figure 30-3, will automatically open.
3 4
5 6
Figure 30-3. The Specify Field dialog is used to establish a reference to a field in a selected table occurrence
594
Chapter 30 ■ Creating Layout Objects
The Specify Field dialog is used to identify the field definition assigned to a field object on the layout.
The dialog includes the following controls:
1.
Table Occurrence — This pop-up menu lists every table occurrence defined
in the database with the default selection being the layout’s assigned occurrence.
At the bottom of the menu is a Manage Database shortcut.
2.
Fields — This area lists every field defined within the selected table occurrence.
Click to select the field you want to assign to the selected field object.
3.
Create label — Check this box to have FileMaker automatically create a field
label next to the field object on the layout.
4.
Manage Database — This button provides an additional shortcut into the Manage
Database dialog to quickly create or edit fields without leaving the Specify
Fields dialog.
5.
Cancel — Click this button to close the dialog without saving any changes.
If this button is clicked during the automatic process of adding a field to a layout,
the field will not be added to the layout and its temporary blank instance will
be removed. However, if this dialog is opened to edit an existing field, the field
object on the layout will remain unchanged.
6.
OK — Click this button to close the dialog and update the field object on the
layout.
Once finished, the field object will remain selected and will display the name of the selected field
definition that it represents, as shown in Figure 30-4. If the Create label check box in the Specify Field
dialog was selected, a text object will be present to the left of the field and contain the full name of the field.
Figure 30-4. The newly added field object selected on the layout with a corresponding label
595
Chapter 30 ■ Creating Layout Objects
To reassign the reference for a field object, open the Specify field dialog using any of these methods:
• Double-click on the field object.
• Bring up the object’s contextual menu and choose the Specify field option.
• Select the field and then click the pencil icon next to the Display data area of the
Field group on the Data panel of the Inspector.
Once open, the Specify field dialog will have the current table and field assignment selected, which
can each be modified to point to another table occurrence and/or field. Then, click OK to save the change.
■■Note When a field’s name is technically descriptive or arranged to accommodate sorting in the
development environment, the layout instance will require an edited label. For example, a field defined as
Contact Name First might have a layout label of First Name or just First. If dynamically linked field labels
are desired, the field’s defined name must match whatever text one wants displayed on layouts.
A label that has been modified and unlinked from the defined field can be deleted and re-created as
a dynamically linked label by reopening the Specify Field dialog for the field and selecting the Create
label check box before clicking OK. The label will reappear as a dynamically linked value.
596
Chapter 30 ■ Creating Layout Objects
To change the control style, select a field and open the Field group on the Data panel of the Inspector.
Click the Control style pop-up menu, shown in Figure 30-5, and select the desired style.
Figure 30-5. The Control style pop-up menu is used to change the appearance, options, and behavior of a field
Once a control style is selected, the options in the shaded area of the Inspector beneath the pop-up
menu will change to reflect the choice, enabling only those options that are applicable.
■■Note The ability of a user to view or edit any field can depend on many factors including the field’s
configuration and what access privileges the user is granted based on their login credentials. The assumption
throughout this chapter is that a user has full access, which may not be the case when a database uses
security settings.
597
Chapter 30 ■ Creating Layout Objects
Edit Box
An Edit box is the default field control style that renders a field as a box into which the user can type,
paste, or drag information. These can vary in size to accommodate data ranging, including these shown in
Figure 30-6:
• A single line able to contain a short piece of text.
• Multiple lines or paragraphs of text.
• A scroll bar to allow entries longer than the size of the field object.
Any field data type can be formatted as an edit box even though the content doesn’t allow for multiple
lines. For example, a date field can be formatted with multiple lines and a scroll bar even though, by its
nature as a date container, it can only contain a date.
■■Note Container fields are automatically locked to an Edit box control style.
598
Chapter 30 ■ Creating Layout Objects
Pop-Up Menu
A pop-up menu is a field control style that renders the field as a menu that pops up a list of choices when the
user clicks into the field in Browse mode, as shown in Figure 30-8. The list of options contained in the menu
is provided by a value list and allows a user to enter a value into a field, replacing any previously entered
value, with a simple click of an item from the menu. This entry option helps to saves time and maintains
consistency by avoiding mistakes for commonly used values.
599
Chapter 30 ■ Creating Layout Objects
Figure 30-8. Example of a pop-up menu in both a resting state (top) and open with active focus (bottom),
the current field value indicated with a check mark and a scroll arrow at the bottom indicating the presence of
additional values below.
If the entire list can’t fit on the screen, it will truncate and display an up or down arrow icon indicating
the presence of additional values out of visual range in one or both directions.
600
Chapter 30 ■ Creating Layout Objects
A user can select a value from the list using any of the following methods:
• Position the cursor onto any item in the list and click.
• Begin typing several letters of the desired value to “key scroll” down. Once the desired
value is highlighted, type the Enter key to choose that value and enter it into the field.
• Use the Up or Down arrow keys to navigate up or down the list until you reach the
desired value. Then type the Enter key to choose that value.
Once the user selects a value, it becomes the field value. When the menu is reopened, that value will
have a check mark preceding it in the list, indicating its status as the current value.
Figure 30-10. The Other dialog in which a user can type any value into the field, bypassing the assigned value list
601
Chapter 30 ■ Creating Layout Objects
• Allow editing of value list — Check this box to automatically add an extra menu
item of “Edit” to the end of the values displayed in the field’s pop-up menu. When a
user chooses Edit in the menu, a small dialog window opens, allowing them to edit
the actual contents of the value list, as shown in Figure 30-11. This option is only
enabled when the value list items are generated using custom values (Chapter 11,
“Using Custom Values”).
Figure 30-11. The Edit Value List dialog in which a user edits the actual items available in the assigned
value list
• Override data formatting with value list — This box performs a rather subtle
function that is useful when the value list assigned to the field is generated from two
fields of differing data types. Without this function, the two values will be displayed
correctly in the menu but, once placed into the field, will only display one value.
With this option selected, the difference in data types between the two fields will be
remedied, and the field will display both values properly.
Drop-Down List
A drop-down list is a field control style that renders a field as a combination of an edit box with an attached
menu of values, as shown in Figure 30-12. This allows a user a choice of typing a unique value or choosing a
preexisting value from a list.
602
Chapter 30 ■ Creating Layout Objects
Figure 30-12. Example of a drop-down list in both a resting state (with and without optional arrow icon) and
open with active focus
The behavior of the drop-down list is like a pop-up menu. When the list of values exceeds the space
available, a scroll bar appears indicating the presence of additional values. A user can use the cursor or
arrow keys to scroll the list up or down.
Selecting a value from the list can be achieved using any of the following methods:
• Position the cursor onto any item in the list and click.
• Begin typing several letters of the desired value to “key scroll” down. Once the
desired value is highlighted, type the Enter key to choose that value and enter it into
the field.
• Use the Up or Down arrow keys to navigate up or down the list until you reach the
desired value. Then type the Enter key to choose that value.
603
Chapter 30 ■ Creating Layout Objects
Once the user selects a value, it becomes the field value. When the menu is reopened, that value will be
highlighted in the list, indicating its status as the current value.
604
Chapter 30 ■ Creating Layout Objects
Checkbox Set
A checkbox set is a field control style that renders the field as a set of boxes, each with a text label, as shown
in Figure 30-14. These allow a user to select or unselect individual options from the list with a click of the
mouse.
Figure 30-14. Example of a checkbox set for the Company Industry field
Unlike a pop-up menu or drop-down list, if given enough layout space, a checkbox set displays every
item in the list all at once. This makes it much easier for a user to quickly find and select an item. Instead of
scrolling up and down a lengthy list, users can visually scan the entire list, locate the item(s) they are looking
for, click to select, and enter the value into the field.
Checkbox sets are specifically intended to facilitate the entry of multiple items into a single field.
As the user checks boxes, the corresponding values are inserted into the field as a list of carriage
return-delimited values.
605
Chapter 30 ■ Creating Layout Objects
Figure 30-16. Example of a radio button set for the Company Industry field
606
Chapter 30 ■ Creating Layout Objects
Like checkbox sets, the radio button control style allows a user to see all the available values at once.
However, unlike check boxes, radio buttons are specifically intended to facilitate the entry of a single item
into a field. As the user makes one selection, the corresponding value replaces the previous value in the field.
While not obvious to users, bypassing this restriction is possible and will be discussed later in this section
(“Bypassing Value List Entry Restrictions”).
The following control options are available for a Radio button set:
• Values from — This pop-up menu contains every value list defined in the current
database file. Select one to assign it to the selected field as the source of available
values. Clicking the adjacent pencil icon will open the Manage Value Lists dialog
allowing direct access to create, edit, or select value lists (Chapter 11).
• Allow entry of other values — Like the same option for Checkbox set, enabling
this option will automatically add an “Other” radio button at the end of the values
displayed in the field. When the user selects this option, an Other dialog will appear
displaying any current selection from the field and allows them to add or replace it
with a different value, including one not on the value list.
Unselecting Values
The Radio button format doesn’t provide an intuitive method for removing a selection and leaving the field
empty. To clear all selections from a Radio button formatted field use any of these methods:
• To deselect an individual value, click on a selected value while holding down the
Shift key.
• If the Other option is enabled, click that and edit the value(s) in the dialog.
• To clear the field completely, click anywhere within its borders and type the Delete key.
Drop-Down Calendar
A drop-down calendar is a field control style that renders the field as a combination edit box with an optional
graphical calendar that drops down attached to the bottom of the field, as shown in Figure 30-18. This allows
a user a choice between typing a date manually into an edit box or choosing a date using a familiar calendar
graphic.
607
Chapter 30 ■ Creating Layout Objects
Figure 30-18. Example of a drop-down calendar in both a resting state (with and without optional icon) and
open with active focus
The calendar panel has several controls, shown in Figure 30-19, that assist a user in quickly locating a
desired date.
1 2
3 4
608
Chapter 30 ■ Creating Layout Objects
1.
Month & Year — The heading displays the currently viewed month and year.
2.
Step by Year — The small up and down arrows will step backward or forward
one year at a time for the current month.
3.
Step back — The left arrow will step backward to the previous month.
4.
Step forward — The right arrow will step forward to the next month.
5.
Calendar — Within the calendar area, a user can click on a date to select and
enter it into the corresponding field. Using only the keyboard, the arrow keys will
navigate around the days and the Enter key will select and enter the current date
selected into the field.
6.
Today — This area always displays the current date and, if clicked, will enter that
into the corresponding field and close the calendar.
■■Note The Drop-down calendar control style can be used with non-date fields like a text or timestamp
field. When using it with text fields, the selected value will be entered as a text string. When used with
timestamp fields, the date selected will be entered with the current time.
609
Chapter 30 ■ Creating Layout Objects
Figure 30-21. Examples of a concealed edit box, both with focus and without, each displaying the same entry
■■Caution Concealed edit boxes are intended to provide minimal security only. The data in the field is not
encrypted. It is only obscured from view on layouts but continues to be accessible to scripts and calculations,
which can access and manipulate the data as they would any other field.
610
Chapter 30 ■ Creating Layout Objects
Figure 30-22. An example of a value list generated from the contents of two fields
A Contact record must contain the Record ID of a Company in the Contact Company ID field to form the
relational link between the two. This mandates that the first field in the value list be the Company::Record ID.
However, with only this field, the value list will display a list of id numbers and be rather useless for most
users. If a user doesn’t know the id of the company, the list will be no help to them. If they do know the id of
the company the list isn’t required. So, this alone isn’t adequate when using lists to aid users in entering a
match field value used in a relationship.
The Also display values from second field option allows items in a value list to be pulled from the
actual values of two fields to create a list of combined values: in this case, the id and the name of the Company
record. The first value continues to provide the Record ID and the second value provides a human-friendly
name that corresponds to that id. By adding the Company Name to the list, the user can select based on the
second field while the first field is what is entered in the field.
This may seem clear in terms of generating a list. However, when applied to a drop-down list or pop-up
menu layout object, there are subtle implications here that may influence your choice of object control type
and the use of the Show values only from second field option in the value list.
Using Two-Field Value Lists with the Drop-Down List Control Style
When the dual-field value list is assigned to the Contact Company ID field as a drop-down list using that
configuration, it will display a list of values containing the Record ID and Company Name fields, as shown in
Figure 30-23.
611
Chapter 30 ■ Creating Layout Objects
Figure 30-23. The value list assigned as a drop-down list to the Contact Company ID field
When used in this configuration, the user can ignore the id portion of the values in the list and focus
on selecting a company by name. Once they select a value, the id is entered in the field and the list will
disappear. Since, the field will contain and display only the id, a second field will be required on the layout to
display the Company Name. This can be any of the following depending on needs or preference:
• A field object referencing the Company Name field through a relationship.
• A calculation field locally created in the Contact table that pulls the Company Name
field value through a relationship.
• A text field locally created in the Contact table that auto-enters the Company Name
field value through a relationship.
While this method works fine, some find it a little visually cluttered to see both the id and the name
in the list and prefer the id be hidden. This can be done by enabling the Show values only from second
field check box on the value list. However, that results in possible confusions as the user sees a list of
company names but their selection is placed into the field as an id, as shown in Figure 30-24.
Figure 30-24. The value list with the id hidden shows only company names while still placing the id in the field
In the past, this led developers to pursue more creative solutions of overlapping the two fields so that
the user only sees the company name in the list and the field without realizing that the id was driving the
whole process. However, there is a much more professional and less contrived method of achieving the same
end using the pop-up menu control style.
Using Two-Field Value Lists with the Pop-Up Menu Control Style
When using the dual-field value list with the pop-up menu control style, there is no difference between
what a user sees in the list and what they see in the field in its resting state, as shown in Figure 30-25. In both
cases, the user sees the actual value they selected. In this case, it is both the id and the name.
612
Chapter 30 ■ Creating Layout Objects
Figure 30-25. A dual-field value list assigned to a field using the pop-up menu control style displays both
fields in its resting state
Since both fields will be displayed in the value list, this method eliminates the necessity of adding
another field to the layout exclusively to display the second field in the value list. Further, by enabling the
Show values only from second field check box on the value list, the field will display only the second
field, the company name, both in the open menu and the field at rest, as shown in Figure 30-26.
Figure 30-26. A dual-field value list showing only the second field in the menu will continue displaying that
value when the field is at rest
Using this method, the field still contains only the id of the related Company record while displaying only
its name. This completely hides the functional aspect while providing a polished, user-friendly interface
when selecting from the menu and viewing the field in its resting state.
These rules are not enforced except by implication in the method of interacting with the field through
the control style interface elements. A pop-up menu and radio buttons both do not offer any obvious
method to select multiple items or to make an entry not on the list. Similarly, a drop-down list seems to
allow only a single value while a checkbox set without the setting to allow other values appears to only
permit value list selections and no other values. However, these rules are easily bypassed if you know how
and this can be either a benefit to allow users a more flexible environment or a developer’s worst nightmare.
Disabling the Allow entry of other values setting doesn’t stop someone from entering other
values and there are ways to make multiple selections with each of the four control styles. It is important
to understand that these restrictions are cosmetic only and you must take explicit steps to stop users from
bypassing them if it’s important.
613
Chapter 30 ■ Creating Layout Objects
■■Note This is a field definition setting and will apply to every use of the field on any layout including those
where a value list-driven control style is not used!
Let (
list.items = ValueListItems ( Get ( FileName ) ; "<value.list.name>" ) ;
;
Case (
IsEmpty ( FilterValues ( list.items ; Self ) ) ; "" ) ;
Self
)
)
614
Chapter 30 ■ Creating Layout Objects
In the formula, the ValueListItems function puts a list of all the items available in the value list into a
list.items variable within the Let statement. Then, a Case statement uses the FilterValues function to
remove every item from list.items except what was entered into the field. If the result is an empty string,
as detected by the IsEmpty function, we know that the entered value is not present in list.items and can
replace it with an empty string. If the value is present, it can remain.
Validating multiple values in a field using an auto-enter calculation would require a recursive custom
function (Chapter 25), which checks the values one by one.
■■Note This is a field definition setting and will apply to every use of the field on any layout including those
where a value list-driven control style is not used!
■■Note This is a layout object setting and will only apply the field where configured and not necessarily on
every instance of the field on every layout.
615
Chapter 30 ■ Creating Layout Objects
Case ( PatternCount ( Self ; "¶" ) > 0 ; GetValue ( Self ; ValueCount ( Self ) ) ; Self )
■■Note This is a field definition setting and will apply to every use of the field on any layout including those
where a value list-driven control style is not used!
■■Note This is a layout object setting and will only apply to the field where configured and not necessarily on
every instance of the field on every layout.
Using Placeholders
A field can be configured with a placeholder text value that will be displayed in the field whenever it is
empty. A placeholder can be used to display the name of the field in lieu of an actual field label or it may
contain a short prompt to action meant to augment the field label. This essentially gives you three options:
no placeholder, a placeholder as field label, or a placeholder as a prompt to action, each of which is
demonstrated in Figure 30-27.
616
Chapter 30 ■ Creating Layout Objects
Figure 30-27. An example of three instances of the same Company Name field: one with no placeholder text,
one with the field name as the placeholder, and one with a prompt message as the placeholder.
This example uses three instances of the same Company Name field, emphasizing the fact that the
placeholder setting is applied to the field as a layout object and not to the field definition itself. Therefore,
multiple instances of the same field on the same or different layouts can have a completely different
placeholder value and must be configured separately.
■■Note A field that is configured as a Checkbox set or Radio button can’t have a placeholder text value.
Figure 30-28. The controls for placeholder text from the Field group of the Data panel of the Inspector
Case (
Get ( WindowMode ) = 0 ; "This is the browse mode placeholder" ;
"This is the find mode placeholder"
)
617
Chapter 30 ■ Creating Layout Objects
■■Caution Since the data displayed in these fields is the placeholder value and not actually present in the
field, there is no way to use this information for anything other than display. For example, it can’t be exported
and can’t be referenced in other formulas or used by script steps.
Figure 30-29. A text field defined with five repetitions displayed on a layout in both vertical and horizontal
arrangement
The Show repetition controls, shown in Figure 30-30, are accessed from the Field group of the Data tab
of the Inspector. The number of defined repetitions for the field is displayed in parentheses. The unlabeled
Start and End text areas allow control over which and how many repetitions are visible on the layout. The
Vertical and Horizontal buttons allow control over the orientation of the repetitions.
618
Chapter 30 ■ Creating Layout Objects
Each instance of a repeating field on a layout can be configured to include any one or group of
consecutive repetitions within the range defined by the field options. For example, each repetition can
be displayed individually as if they were separate fields or as partial groups of repetitions, both shown in
Figure 30-31.
Figure 30-31. Several examples showing the flexibility of configuring repeating fields individually or in groups
■■Note Other field settings for Behavior and Data Formatting are located on the Data panel of the
Inspector and were discussed in Chapter 29.
619
Chapter 30 ■ Creating Layout Objects
Static Text
On a layout, static text is an object that contains an unchanging string of characters. Static text can be created
one of two ways while in Layout mode:
• Create a Text Object — Choose the Text tool in the toolbar and then click and drag
to define an area for the text object. When you release the cursor, the object will be
created and have editing focus allowing you to type.
• Convert a Field Label — As mentioned earlier, a field label will dynamically update
its content to match the name of its corresponding field until it is edited. Once
modified, the dynamic label becomes a static text object.
Text objects can contain rich formatting and multiple paragraphs.
{{SymbolKeyword}}
For example, instead of typing a date on a layout as a piece of static text, you can insert the following
symbol in a text object, indicating to FileMaker that it should be rendered with the current date:
{{CurrentDate}}
There are 100 different symbols available, each corresponding to a Get function (Chapter 22).
Symbols may be combined with other symbols or static text in a single object. For example:
A symbol can be manually typed or added to a layout by selecting one from the Insert menu. When
using the menu, the symbol will be inserted into an existing text object if there is one with edit focus
currently active, otherwise a new text object containing the symbol will be created.
Merge Fields
A merge field is a symbolic tagging format that allows a field’s text content to appear on a layout in a non-
editable text object, optionally combined with static text.
Merge fields are made up of a field name enclosed in left-shift (<<) and right-shift (>>) symbols,
following this pattern:
<<FieldName>>
<<TableName::FieldName>>
When referencing a field local to the current layout’s table, only the field name needs to be specified.
A field from a related table must include the relationship name to indicate which table occurrence to pull
through.
620
Chapter 30 ■ Creating Layout Objects
For example, a Contact name and Company name might be placed directly on a layout with the
following text:
Contact <<Contact Name First>> <<Contact Name Last>> at <<Contact | Company::Company Name>>
Merge fields may be combined with other merge fields, other text and symbols. They can be added
to a layout by selecting the Insert > Merge Field menu. As with symbols, the merge field tag will be
inserted into an existing text object if there is one with edit focus currently active; otherwise a new text object
containing it will be created.
Merge Variables
A merge variable is a symbolic tagging format that allows a global variable to be rendered within a text object
on a layout.
Merge variables are made up of a variable name enclosed in left-shift (<<) and right-shift (>>) symbols,
following this pattern:
<<$$VariableName>>
Merging variables on a layout works exactly like merge fields and dynamic symbols. They can be used
in any combination with other merge variables, text, symbols, and merge fields. Use the Insert > Merge
Variable menu to add one into the current text object with edit focus or a new object.
621
Chapter 30 ■ Creating Layout Objects
Buttons are configured using the Button Setup dialog, which automatically opens when a new button
is created. This dialog can also be opened by any of the following methods:
• Double-click on an existing button.
• With a button selected, click the Format > Button Setup menu item.
• Open the button’s context menu and select the Button Setup menu item.
Figure 30-33. The default Button Setup dialog for a new button.
622
Chapter 30 ■ Creating Layout Objects
■■Tip You can create dynamic button labels using merge fields within the name of the field. For example, this
button name will put a Contact record’s first name field into the button name, creating a personalized button for
each record:
2
4
3
623
Chapter 30 ■ Creating Layout Objects
3.
Icon Size Slider — Drag the slider left or right to shrink or enlarge the size of the
icon or click either of the two squares to adjust the size one pixel at a time.
4.
Icon Size Setting — This box displays the current size of the icon. You can type a
new number to quickly set a new size.
As you adjust the selected icon and size, the button will update in real time on the layout, giving you
a preview of how it will appear. Once it appears as desired, continue configuring other options or close the
Button Setup dialog.
■■Note Unlike some measurement settings in the Layout Inspector, the Icon size will always be
displayed in points regardless of units currently selected for the ruler.
Figure 30-35. The Button Action dialog for selecting the script step that the button will perform
The Button Action dialog looks similar in appearance to a Script Workspace dialog (Chapter 34).
Double-click the step from the list on the right to add it as the action for the button. Then click the OK button
to save the selection.
624
Chapter 30 ■ Creating Layout Objects
■■Note When choosing this option, only a single command can be assigned to the button and any
subsequent selection will replace the previous one. If more than one command is required for a button, choose
Perform Script from the Button Setup dialog instead of Single Step, or click the Convert to Script
button in the Button Action dialog. This convenient button will create a new script with a name you specify;
add the selected command and assign the new script to the button all in one step.
Once a step has been assigned to a button, the Action Specification area at the bottom of the Button
Setup dialog will display the command selected, as shown in Figure 30-36.
Figure 30-36. The lower portion of the Button Setup dialog configured to run a Single Step
625
Chapter 30 ■ Creating Layout Objects
2 3
626
Chapter 30 ■ Creating Layout Objects
5.
Script Buttons — These buttons allow convenient access to the following script
functions:
a. Create — Click to create a new script and open it in the Script Workspace.
b. Delete — Click to delete the selected script(s).
c. Edit — Click to open the selected script in the Script Workspace.
d. Duplicate — Click to duplicate the selected script(s).
6.
Script Parameter — Use this text area to enter any parameter information to send
to the script or use the Edit button to open a Specify Formula dialog to enter a
parameter calculation (Chapter 34, “Exchanging Data Between Scripts”).
Once finished, click OK to save the selection to the button. The options are at the bottom of the Button
Setup dialog, as shown in Figure 30-38.
1 2
Figure 30-38. The options at the bottom of the Button Setup dialog configured to Perform Script
The following three new controls will be available when using the Perform Script action:
1.
Assigned Script — This button displays the name of the selected script. Click to
open and directly edit the script in the Script Workspace.
2.
Script Selection — Click this button to open the Specify Script dialog and select
a different script.
3.
Current Script Handling — This pop-up menu controls how to handle a running
script that is paused. After the button’s script is run, the available options are:
a. Halt Current Script — All running scripts can be halted.
b. Exit Current Script — The paused script will be exited. If another script
called that script, control will be returned to it and it will continue running.
c. Resume Current Script — The paused script will resume running after the
button script.
d. Pause Current Script — The paused script will remain paused.
627
Chapter 30 ■ Creating Layout Objects
Each option available under the Button Action submenu immediately configures the button and/or
opens the relevant dialog while completely bypassing the Button Setup dialog.
• Do Nothing — Quickly removes any assigned action.
• Single Step — Directly opens the Button Action dialog.
• Perform Script — Directly opens the Specify Script dialog.
Popover Button
A popover button is a layout object that expands to make additional interface elements available on a
miniature layout that temporarily overlaps a portion of the current window. While regular buttons can be
configured to perform a specific action, a popover’s action is predetermined; it opens an adjacent, fully
customizable interface from which a user can select from many actions or perform various data entry tasks.
Popovers prevent visual clutter by allowing interface controls to be grouped and compactly stored out of
view while remaining easily accessible with a click when needed.
The expanded pop-up button interface is a small layout that can contain any number and variety of
interface elements just like a regular layout. These have many uses including:
• Button menu — Allows an array of buttons to be hidden until the user clicks to
expand open a menu of all available choices. For example, a menu of print report
options, as shown in Figure 30-40.
628
Chapter 30 ■ Creating Layout Objects
Figure 30-40. An example of an expanded popover button containing an array of buttons for various
printing options
• Task wizard — An interface that walks a user through a multi-option process with
expanded instructional text that would otherwise be too much clutter to include on a
main layout.
• Detailed entry — A calculated summarization of text from multiple fields that is
displayed on a main layout that pops open to make accessible and editable each
individual field.
Popovers are created by choosing the Insert > Popover Button menu or clicking on the Button tool in
the toolbar and choosing Popover Button from the drop-down menu, as shown in Figure 30-41.
Figure 30-41. The toolbar control used to add a new popover button
629
Chapter 30 ■ Creating Layout Objects
Popover
3
4
■■Tip Double-click the popover window to show a gradient control bar and resize handles.
630
Chapter 30 ■ Creating Layout Objects
4
4
5
631
Chapter 30 ■ Creating Layout Objects
5.
Show title bar check box — This check box controls if the title is displayed in the
interface or not.
6.
Script Triggers — This button offers a convenient way to open the Set Script
Trigger dialog for the popover object.
Once configured, the interface of the popover can be customized like a regular layout.
Button Bar
A button bar is a layout object that defines a group of interconnected button segments, as shown in
Figure 30-44. Button bars can run horizontally or vertically, and each segment can be configured as either
a regular push-style button or as a popover button. This allows the placement of different controls together
into a single, uniform layout element.
Figure 30-44. An example of a button bar with one popover button (open) followed by two regular
push-style buttons
632
Chapter 30 ■ Creating Layout Objects
1 2
4 5
This dialog combines the options of the Button Setup and Popover Button Setup dialogs with
controls specific to the button bar.
The top portion of the dialog contains controls pertaining to the overall object. These include:
1.
Bar Orientation Control — These two icon buttons control the direction of the
bar segments allowing a choice of Horizontal or Vertical.
2.
Button Labeling Options — Like a standard button, the button can be labeled
with text, an icon, or both in a variety of orientations. The default selection is a
text label with no icon.
3.
Active Segment — This pop-up menu specifies which segment will be formatted
as “active” by default in Browse and Find modes, with a default selection of None.
The menu includes a list of all the defined segments in the bar, listed by segment
number or by button label, if a label has been assigned. It includes a Specify
option that opens a Specify Calculation dialog allowing entry of a formula
to determine the active segment by returning the Object Name of the desired
segment (from “Position Settings of the Inspector,” Chapter 29).
633
Chapter 30 ■ Creating Layout Objects
4.
Segment Controls — Button bars are created with a default of three segments.
These buttons allow you to add or remove segments as follows:
• The + button will add a new segment after the currently selected segment.
• The – button will delete the currently selected segment.
5.
Current Segment Navigation — These buttons allow you to move back and forth
between the segments to select one for editing.
The bottom portion of the setup dialog contains controls that vary contextually based on the currently
selected segment. These include:
6.
Button Labeling Specification — Like a standard button, this area dynamically
updates the available controls depending on your choice of labeling option
above. By default, it allows for the entry of the button text in the visible field but
will expand to allow selection of an icon and specification of its size. The values
displayed apply only to the selected segment.
7.
Segment Type — This pop-up menu allows specification of the type of button for
the current segment, offering a choice of Button or Popover Button.
8.
Action Menu & Specification — This area dynamically updates the available
controls depending on the type of segment, displaying Button or Popover
Button interface controls accordingly.
Figure 30-46. The Button Setup dialog for a non-button layout object, in this case as text object
The dialog only allows configuration of the button action with the same options as a regular button:
• Do Nothing
• Perform Script
• Single Step
634
Chapter 30 ■ Creating Layout Objects
Tab Control
A tab control is a layout object that makes multiple interface panels accessible one at a time by means of
file folder tabs, like the example shown in Figure 30-47. The object can be configured with any number of
separate panels, each represented by a labeled tab. When the user clicks on one of the available tabs, the
corresponding panel activates and its layout elements are displayed in the rectangular area below while all
other panels are simultaneously obscured from view. Each panel is like a mini-layout and can contain any
number and type of layout objects arranged as they can on a regular layout. A tab panel can even contain
another tab object, creating a hierarchical tab structure.
Active Panel
Figure 30-47. An example of a tab control with four tabs, actively displaying the second tab
635
Chapter 30 ■ Creating Layout Objects
1
7
3 4 5
636
Chapter 30 ■ Creating Layout Objects
The following controls are available on the Tab Control Setup dialog:
1.
Tabs — This area lists the name of every tab panel currently defined for the
control. Click and drag these up or down in the list to rearrange the order.
2.
Tab Name — This text area is used to type a tab name when creating a new panel
and to edit the name of the selected tab. Click the adjacent Specify button to
open a Specify Calculation dialog into which a formula can dynamically
calculate the tab name.
3.
Create — This button will create a new tab with the name entered above.
Tab names do not need to be unique.
4.
Rename — This button will rename the selected tab with the name entered above.
5.
Delete — This button will delete the selected tab(s) without warning, although
the change doesn’t take place on the layout until you click the OK button and
clicking Cancel will reverse any changes.
6.
Default Front Tab — This pop-up menu lists every defined tab name. The
selected tab will be the default active tab when navigating to a record or creating
a new record.
7.
Tab Justification — This pop-up menu allows control over the justification of
the tab labels on the control from the available choices:
• Left
• Center
• Right
• Full
8.
Tab Width — This pop-up menu contains the following options for control over
the width of the tabs:
• Label Width — Set the width of each tab individually based on the width of the
label name.
• Label Width + a Margin of — Set the width of each tab individually based on
the width of the label name with a specifiable margin.
• Width of Widest Label — Set the width of each tab uniformly to the width of
the longest label name.
• Minimum of — Set the width of each tab individually based on the width of the
label name while staying above a specifiable minimum measurement.
• Fixed Width of — Set the width of each tab uniformly to a specifiable fixed width.
9.
Tabs share single style — Check this box to automatically apply any
appearance style settings made to one tab panel to every other tab panel,
maintaining a uniform design.
637
Chapter 30 ■ Creating Layout Objects
Slide Control
A slide control is a layout object that makes multiple interface panels accessible one at a time by means of
swiping left or right on an iOS device with FileMaker Go or by clicking a corresponding navigation dot, like
the example shown in Figure 30-50.
Active Panel
Navigation Dots
1 2
638
Chapter 30 ■ Creating Layout Objects
Portal Rows
Scroll Bar
Figure 30-52. An example of a portal listing every Contact record related to the current Company record
639
Chapter 30 ■ Creating Layout Objects
Layout Interface
Contacts
Portal
Figure 30-53. An illustration of a portal showing related contacts placed on a company layout
In this example, we can think of Company as the parent table and Contact as the child table because we
are viewing a company record on a company layout and seeing one or more linked contacts through the
relationship.
640
Chapter 30 ■ Creating Layout Objects
Figure 30-54. The Portal Setup dialog is used to configure the settings for a portal
641
Chapter 30 ■ Creating Layout Objects
3.
The following row formatting options are available:
• Initial row — This number indicates where in the range of related records to
begin displaying in the portal with any prior records excluded.
• Number of rows — This number controls how many rows should be included
in the portal at its minimum size. All related records after the Initial row
will always be included in the portal, but some may be out of the scroll range,
not initially visible and only accessible if scrolling is enabled. If the portal is
configured for auto-sizing (Chapter 29) then the number of rows will increase as
the window height is increased.
• Use alternate row state — Check this option to format portal rows with an
alternating fill color to help delineate them and improve a user’s visual clarity
when glancing along the objects included within.
• Use active row state — Check this option to apply special formatting to help
visually indicate which row is currently active.
642
Chapter 30 ■ Creating Layout Objects
Figure 30-55. The check box in the Edit Relationship dialog enables a blank portal row that auto-creates
new records
To create a new record, a user or script must enter a field within the blank row, begin typing, and then
move to another field or commit the record. This will instantly cause the following events to occur:
• A new record will be created in the remote table with the field value(s) entered
by the user.
• The new record will automatically populate each match field with the appropriate
value to cause it to be related to the currently viewed parent record.
• The new record will appear in the portal.
• Another blank row will appear for the creation of additional new records.
The blank row is only an interface feature, implying the option for creating a new record. However, it
does not actually exist in the related table until data is entered. This means that it will be programmatically
ignored and will not affect functions that summarize related records such as Count, List, Max, Min, Sum, etc.
■■Caution Using this feature may be confusing for some users since the empty new record row will appear
to them like a related record with empty fields. This may cause them to either attempt to delete the empty row
thinking it is leftover data; or not attempt to delete an actual leftover record thinking it is the new record row.
For this reason, many professional developers do not enable this feature in their solutions and prefer to write a
script to create a related record.
643
Chapter 30 ■ Creating Layout Objects
■■Note An example of each of the scripts described in this section appear in Chapter 35, “Scripting Portal
Functions.”
644
Chapter 30 ■ Creating Layout Objects
■■Caution The default message in the dialog is vague and has the potential to be confusing to the users.
Configuring the portal to Use active row state may help since the selected row will be highlighted. However,
the non-specific message is still far from ideal. To create a more professional interaction, turn off the direct
delete option and put a Delete button or icon into the portal row that will handle the process with a more
detailed dialog message.
645
Chapter 30 ■ Creating Layout Objects
Figure 30-57. A portal with a Delete button added to the right side to allow a user to click to run a script that
will delete a specific record
The button can be linked to the Delete Portal Row script step, but that is essentially the same function
as them typing Delete and will have the same vague dialog message. Instead, write a script that loads the
Record ID field of the selected row into a variable; navigates to a layout for the table occurrence providing
records for the portal; performs a search for the record; presents a warning dialog; and, if the user confirms
their intent, deletes the record before returning to the original layout. Since you are creating this script
yourself, you can control the dialog message, providing a much clearer warning to the user like the one
shown in Figure 30-58.
Figure 30-58. An example of a robust confirmation dialog for a script when deleting a portal row
646
Chapter 30 ■ Creating Layout Objects
Figure 30-59. An example of a basic portal filtering field placed near a portal to filter records based on the
user’s entry
■■Caution Filtering applies only to related records displayed in a portal and does not affect the actual
relationship. Therefore, any field or script calculations that access records through the relationship will continue
to see all records even when the layout displays a filtered set.
■■Tip To have the filter field apply to all records in the parent table and to avoid the record locking (showing
busy for other users) use global storage on that field. Once the user enters filtering criteria, it will apply for any
record during the session until they change the criteria.
647
Chapter 30 ■ Creating Layout Objects
After this, an or operator followed by a second condition can begin adding filtering criteria. Using the
PatternCount function, we can specify a partial or full match between the Contact Address State field and
the text the user has entered in the filter field, expanding the formula to the following:
Save the formula and the Portal Setup, then test the function. When a state abbreviation is typed into
the filter field, the portal rows should only include those records matching the text you enter.
■■Note For the portal to update after typing into the filter field, the record must be committed. To dynamically
update the results, use the ObjectModify script trigger (Chapter 37) to run a script that commits the record and
re-enters the filter field after each keystroke.
648
Chapter 30 ■ Creating Layout Objects
In the Contact Portal example, the formula can be expanded to find matches in multiple Contact
fields based on the text in the single filter field like this:
Now, in the example shown in Figure 30-60, typing “SC” in the filter field will result in a match of two
records: one based on the state and another based on a partial match in the city.
Figure 30-60. The portal filtered by multiple fields in the related table
649
Chapter 30 ■ Creating Layout Objects
■■Note Custom web addresses must begin with the correct scheme such as http://, https://, ftp://,
or file://.
650
Chapter 30 ■ Creating Layout Objects
1 4
The following controls are available in the Web Viewer Setup dialog:
1.
Choose a Website — This list displays all the available options for generating a
web address. Choose from the list of templates for standard data-driven websites
or select Custom Web Address to write your own URL or HTML calculation formula.
2.
Web Address — This text area displays the address or formula for generating an
address that will be displayed in the web viewer. The predefined options will
insert a ready-made calculation with links to contextual website parameter fields
on the top right of the dialog. Custom addresses or formulas can be entered
directly into the text area or into a Specify Calculation dialog by clicking the
adjacent Specify button.
3.
Web Viewer Options — This set of check boxes control the following features of
the viewer:
• Allow interaction with web viewer content — Check this box to allow the
user to interact with the displayed web page like they would in any standard web
browser.
• Display content in Find mode — Check this box to cause the web viewer to
continue displaying content when the window is placed into Find mode.
• Display progress bar — Check this box to include a progress bar in the footer
showing the percentage of completion for loading the page.
651
Chapter 30 ■ Creating Layout Objects
• Display status messages — Check this box to have the viewer include a text
footer that displays the loading status of the page.
• Automatically encode URL — Check this box to allow FileMaker to
automatically percent-encode any special characters contained in the address
specified. For example, a space will be converted to %20 automatically if this box
is checked.
4.
Website Parameters — This set of input controls will display a set of input
options for the predefined websites, which will be automatically inserted into the
URL when the web page is rendered in the viewer. You can type a value directly
into a field or click the adjacent button and choose from one of two options:
• Specify Field Name — Choosing this option will open a Specify Field dialog
and allow you to select a field that will provide the required input value.
• Specify Calculation — Choosing this option will open a Specify
Calculation dialog and allow you to enter a custom formula to determine the
required input value.
■■Note Choosing to open an image or link into a new window will leave FileMaker and open in your
computer’s default web browser application.
652
Chapter 30 ■ Creating Layout Objects
data:[<media type>][;base64],<data>
"data:text/html,
<html>
<head>
</head>
<body>
<h1>Hello World</h1>
</body>"
The page code can include a <style> tag to control text formatting with cascading style sheets (CSS).
This simple example modifies the color of the h1 style:
"data:text/html,
<html>
<head>
<style>
h1 {
653
Chapter 30 ■ Creating Layout Objects
color: green;
}
</style>
</head>
<body>
<h1>Hello World</h1>
</body>"
The page code can include a <script> tag to include JavaScript functions. This simple example will
open an alert dialog when the page loads:
"data:text/html,
<html>
<head>
</head>
<body>
<script>
alert('Hello World!')
</script>
<h1>Hello World</h1>
</body>"
■■Tip Remember when writing html code for a web viewer that you are doing so within a FileMaker
calculation formula. All text must be enclosed in quotation marks, and any quotes within that text must be
escaped with a preceding backslash. To avoid this, the entire HTML code can be stored in and loaded from a field.
"data:text/html,
<html>
<head>
</head>
<body>
<h1>" & Company::Company Name & "</h1>
</body>"
654
Chapter 30 ■ Creating Layout Objects
"data:text/html,
<html>
<head>
</head>
<body>
<h1>" & Company::Company Name & "</h1>
<img src='data:image/imagemac;base64," & Base64Encode ( Company::Company Logo ) & "'>
</body>"
655
Chapter 30 ■ Creating Layout Objects
Charts are configured within a complex Chart Setup dialog, shown in Figure 30-64, which opens
whenever a new chart object is inserted onto a layout. This dialog can be reopened for an existing chart
object by any of the following methods:
• Double-click on the chart object.
• Open the chart object’s contextual menu and select the Chart Setup option.
• Select the chart object and choose the Format > Chart Setup menu item.
1 2
The Chart Setup dialog is broken up into the following two sections:
1.
Preview — This area will show a preview of the chart based on the configured
settings and the current window’s context (table, found set, sort order, etc.).
2.
Controls — This area contains all the controls used to define and style the chart.
It contains three toggle sections that display tools and settings contextually based
on the chart type selected and other options:
• Chart — Set the chart title, type, axis data information (field reference or
calculation results), legends and more.
• Styles — Set the chart style, color scheme, background, gridlines, legend
positions, borders, and more.
• Data Source — Offers a choice for the source of the axis data from Current
Found Set, Current Record (delimited data), or Related Records.
656
Chapter 30 ■ Creating Layout Objects
The charting features and interface controls are too numerous to cover in complete detail so we will
explore simple examples using two chart types. With an understanding of general charting methodology and
features from other popular applications such as Microsoft Excel, it should be relatively easy to explore the
interface and figure out how to create additional charts.
Creating Charts
Charts can be created using data from the found set of records, a group of related records, or from
calculated data.
4
1
Figure 30-65. The configuration for a pie chart based on calculated data
657
Chapter 30 ■ Creating Layout Objects
3.
Slice Data — This area must result in a carriage return-delimited list of
numeric values that define the slices of the pie chart that correspond to each of
the Category Labels defined above. Type directly into the text area or click the
adjacent button to get the same two options for Category Labels.
4.
Options — These are optional settings to include labels on the chart showing the
actual value and/or percentage of the whole.
5.
Chart Data — From the Data Source section of the controls, select Current
Record (delimited data) to instruct the chart engine to use data from the
context of the current record only.
This example will generate a pie chart with three sections, as shown in Figure 30-66.
1000¶250¶650
658
Chapter 30 ■ Creating Layout Objects
To get started, insert a chart onto a layout, and then configure the settings as shown in Figure 30-67.
4
1
Figure 30-67. The configuration for a column chart summarized from the found set
■■Tip Creating charts from found sets can be a little confusing. It is like creating a report with a sub-summary
part in that only records in the found set will be included and the sort order controls how a summary field
counts records into subgroups.
659
Chapter 30 ■ Creating Layout Objects
Figure 30-68. An example of a column chart displaying the number of contact records for each state
Remember, for this chart to summarize correctly, the records must be sorted by the x-axis (State) and
the y-axis must be a summary field, counting the number of records by using a field such as the Record ID.
Summary
In this chapter, we discussed details about the objects that can be placed on layouts to allow a user to view
and interact with the data structure and script functions of the database.
660
CHAPTER 31
Manipulating Objects
Once objects are placed on a layout, there are various ways to manipulate them. In this chapter, we will focus
on manipulating objects, covering:
• Selecting
• Resizing
• Moving
• Arranging & aligning
• Hiding
• Conditional formatting
• Understanding tab order
• Naming objects
Selecting Objects
To select an object, click on it with the cursor or click on the layout near the object and drag the cursor
toward it. The object will become highlighted with an outline that includes eight sizing handles, which are
small dots located at the four corners and midway along each side, as shown in Figure 31-1.
Figure 31-1. An object at rest vs. a selected object which is highlighted and has eight sizing handles
When multiple objects are selected, they share one set of sizing handles among them, outlining the
overall space of the group. See Figure 31-2.
Figure 31-2. Objects selected together will have collective sizing handles
Objects can be de-selected by clicking on the background of the layout or by selecting another object.
To de-select one of a group of selected objects, click on the object while holding the Shift key.
Resizing Objects
Objects can be resized using the following methods:
• Click on one of the eight sizing handles and drag the cursor away or toward the
center of the object(s).
• Use the Position settings of the Position panel of the Inspector. Type a new
measurement for the Width or Height settings followed by the Tab or Enter key and
the object will instantly adjust the object’s size.
• Use the Resize To feature described later in this chapter.
Moving Objects
Once one or more objects are selected, they can be moved to a new location by clicking and dragging.
■■Caution Shape objects with no fill color are a little tricky to move by dragging. Clicking in the center of an
object will click through the object onto objects behind it or the background of the layout. Instead, carefully click
on the edge of the shape to grab and drag it.
In addition to dragging, selected objects can be moved using three other methods:
• Use the Up, Down, Left, or Right arrow keys to push the selection one pixel at a time
in one direction.
• Use the Position settings of the Position panel of the Inspector (Chapter 29). Type
a new measurement for the Left, Right, Top, or Bottom positions followed by the
Tab or Enter key and the object will instantly shift to that new position.
• Use the Arrange and Align features described later in this chapter.
662
Chapter 31 ■ Manipulating Objects
Ruler
The ruler is a horizontal and vertical strip running along the entire left and top of a window’s content area
that displays incremental markings based on a chosen unit of measurement: inch, centimeter, or point.
The ruler, as shown in Figure 31-3, is only visible in Layout mode when the View > Rulers menu is active.
Figure 31-3. The Ruler helps you to drag an object into a precise position on the layout
■■Tip The unit of measurement can also be changed from the ruler’s contextual menu.
663
Chapter 31 ■ Manipulating Objects
When editing text directly on a layout, the top ruler transforms into a gray bar with a text ruler overlay that
spans the width of text object, as shown in Figure 31-4. This ruler controls indentation, margins, and tabs within
the text object in a similar manner to the text ruler accessible in Browse mode when editing a field.
Figure 31-4. The top ruler transforms into a text ruler sized to the object being edited
Grid
The layout grid is a sequence of evenly spaced horizontal and vertical lines overlaid on a layout background
that forms a regular grid of minor and major areas. These lines, resembling graph paper, are only visible in
Layout mode when the View > Grid > Show Grid menu item is active or the corresponding check box in
the Inspector is enabled (Chapter 29, “Grid”).
When visible, the lines can visually assist in uniform alignment of objects. Activating the View > Grid >
Snap to Grid feature in the menu or the Inspector will cause an object being dragged to be subtly attached
to the next grid line in the direction of travel.
Guides
A layout guide is a movable blue line used to align objects and define regions of a layout. Multiple guides can
be placed horizontally or vertically on the layout, as shown in Figure 31-5. Guides don’t print and are only
visible in Layout mode when the View > Guides > Show Guides menu is active. They are identical in form
and function to the guides in desktop publishing and page layout applications.
664
Chapter 31 ■ Manipulating Objects
When visible, guides can visually assist in uniform alignment of objects. Activating the View > Guides
> Snap to Guides feature in the menu will cause an object being dragged to be subtly attached to the next
available guide line in the direction of travel.
■■Note Guides are layout specific so they must be configured for each layout.
With ruler must be visible, click on a ruler and then drag right or down respectively and release the
new guide at the desired position on the content area. Guides can be repositioned by clicking, holding, and
dragging to a new position or removed completely by dragging them back to the ruler.
Dynamic Guides
As an object is moved around a layout, blue lines called dynamic guides automatically appear and disappear
on or around nearby objects showing alignment and spacing patterns that would result if the object were
dropped in its current location. By showing multiple spatial relationships of groups of nearby objects
relative to the position of the moving object, dynamic guides help to encourage consistency and order when
manually moving an object. Like the grid and manually placed guide lines, objects will be subtly attracted to
dynamic guides.
Activating the View > Dynamic Guides menu item will cause dynamic guides to appear on any layout
when an object is being dragged with the cursor.
665
Chapter 31 ■ Manipulating Objects
When moving an object, no guides will appear when the current position does not align to any other
objects on the layout, as shown in Figure 31-6.
Figure 31-6. A dragged object that does not align with any other objects will show no dynamic guides
As the object is dragged further and begins to align with other objects, dynamic guides will appear, like
the one shown in Figure 31-7. Alignments are shown for left, right, horizontal center, top, bottom, and vertical
center, connecting to one or more other objects.
Figure 31-7. As the object moves into alignment with one or more objects, a guide will appear
When the object is dragged into a position that creates a consistent spacing pattern, those are
highlighted as well, like that shown in Figure 31-8. These appear for horizontal and vertical arrangements
and are displayed simultaneously with alignment guides.
666
Chapter 31 ■ Manipulating Objects
Figure 31-8. Multiple guides can appear showing both alignment and uniform spacing between objects
■■Note Many examples in this chapter are shown with square shapes for illustrative purposes only. Dynamic
guides and other features described will work the same with any combination of different layout object types,
non-uniform arrangements, and varying sizes.
■■Note These functions work in FileMaker like those found in countless other page layout and desktop
publishing applications.
667
Chapter 31 ■ Manipulating Objects
Align
The Align group of functions include commands to automatically align groups of selected objects
horizontally (Left Edges, Center, Right Edges) or vertically (Top Edges, Middle, Bottom Edges).
For example, with several misaligned objects selected, choose the Arrange > Align > Left menu item
to instantly align them along their left border, as shown in Figure 31-9.
Before After
Figure 31-9. The transition from misalignment to Left alignment is instantenous using the Align > Left
function
Resize To
The Resize To group of functions include commands to automatically resize groups of selected objects
to Smallest Width, Smallest Height, Smallest Width & Height, Largest Width, Largest Height or
Largest Width & Height.
For example, with several non-uniformly sized objects selected, choose the Arrange > Resize To >
Smallest Width and Height menu item to instantly resize every object to a uniform size and height based
on the object with the smallest of each, as shown in Figure 31-10.
668
Chapter 31 ■ Manipulating Objects
Before After
Figure 31-10. The transition from non-uniform size (Left) to uniform size (Right) is instantenous using the
Resize To functions
Distribute or Space
Objects can be distributed or uniformly spaced using the Distribute submenu in the Arrange menu or
contextual menu as well as the Space buttons on the Arrange & Align section of the Position panel of
the Inspector. The functions will reposition the objects so that they are uniformly spaced horizontally or
vertically using the outside measurements of the group along the respective axis.
For example, with several non-uniformly spaced objects selected, choose the Arrange > Distribute
> Vertical menu to instantly reposition every object with uniform space between them, as shown in
Figure 31-11.
669
Chapter 31 ■ Manipulating Objects
Before After
Figure 31-11. The transition from non-uniform spacing (Left) to evenly distributed vertical spacing (Right)
using the Distribute function
Rotate
Many objects can be rotated in a clockwise direction 90 degrees at a time by selecting the Arrange > Rotate
menu item, as shown in Figure 31-12.
■■Note The following object can’t be rotated: button bars, charts, popovers, portals, slide controls, tab
controls, and web viewers.
Group
Grouping objects makes it possible to select and manipulate multiple objects as if they were a single object.
Once grouped, they can be resized, moved, formatted as a button, and more.
The objects within the group are “frozen” in place in size and in position relative to one another and can
only be edited as a group. However, most objects such as buttons, button bars, charts, fields, web viewers,
and more can be edited functionally while included in a group by double-clicking directly on the object. In
some cases, an object will need to be ungrouped for editing.
A set of selected objects can be grouped by selecting the Arrange > Group menu item. It is even
possible to group groups into a grouping hierarchy. To ungroup formerly grouped objects, select the Arrange
> Ungroup menu item.
670
Chapter 31 ■ Manipulating Objects
Lock
Locking an object causes it to be uneditable and is a great way to avoid accidental modifications or deletions
of carefully arranged layout items. A locked object can’t be moved, resized, reassigned, reconfigured, or
changed in any way unless and until it is unlocked. When selected, locked objects displays an “x” icon in
place of each sizing handle, as shown in Figure 31-13.
Figure 31-13. A locked object is indicated by a restriction icon in place of sizing handles
An object can be locked by selecting the Arrange > Lock menu item. Once locked, the item will not
respond to any edit commands. Occasionally, when attempting to change a setting in the Inspector, a
dialog will appear stating that the change couldn’t be made because of the object’s locked status. However,
in many cases, the command will just be ignored. For example, selecting a locked object and typing Delete
will result in no action and no error dialog. If the locked object is selected with other unlocked objects,
deleting will successfully delete everything except for the locked object.
An object can be unlocked by selecting the Arrange > Unlock menu item.
Object Stacking
Objects on a layout are stacked in an order relative to other objects based on when they were created. When
two objects are moved together, the one created after the other will appear on top of the first, obscuring it
from view. This is called the stacking order.
There are four commands that affect an object’s position within the stack, as illustrated in Figure 31-14.
Bring To Front
Bring Forward
Send Backward
Send to Back
Figure 31-14. An illustration of all four commands that affect an object’s stack position
671
Chapter 31 ■ Manipulating Objects
Hiding Objects
The Hide objects when setting is a formula that controls whether an object will be visible on the layout. The
feature makes possible conditional interface elements that appear or disappear based on the values in fields,
conditions of the window context, or details about the user’s environment, such as:
• Hide buttons until the appropriate value(s) are entered to make their function
applicable or vary buttons depending on conditions, such as the open or committed
status of a record.
• Hide fields based on the status or type of a record.
• Hide objects based on the window’s mode.
• Hide a chart until enough information has been entered to make it useful.
• Have two overlapping portals or tab controls toggle depending on the type of record.
• Make layout objects only accessible for certain access privilege sets. This can be used
to hide restricted fields and avoid users seeing fields stating “no access.”
The hide formula is entered in the Behavior section of the Data panel of the Inspector. When it evaluates
to a true result, the object will be hidden. When it returns a false value, the object will be visible to the user.
Objects always remain visible in Layout mode.
■■Tip Using the Hide objects when feature with a formula that always returns a true result, short developer
notes can be embedded directly within the content area, next to interface elements to which they refer. For
example, when objects are layered on top of one another, a short piece of red text near them stating “Layered
objects” is a helpful reminder when in Layout mode but could be hidden in Browse mode.
Conditional Formatting
Conditional formatting is a layout feature that defines format combinations that will be applied to an object
when certain conditions are met. Each condition is defined as a custom formula or by selecting one of
twenty predetermined content value conditions.
■■Caution Don’t confuse conditional formatting with text formatting functions. The former affect the
appearance of a object on a layout while the latter affects the actual text content of a field or formula-driven
object text.
672
Chapter 31 ■ Manipulating Objects
The rules for conditionally formatting an object are set in the Conditional Formatting dialog, shown
in Figure 31-15. The dialog can be open when one or more objects is selected and then either:
• Choosing the Format > Conditional menu item.
• Open the object’s contextual menu and select the Conditional Formatting option.
673
Chapter 31 ■ Manipulating Objects
Value-Driven Conditions
The Value is condition compares the text content of the object to one or more static values depending on
the choice of twenty different operators, as shown in Figure 31-16. Once an operator is selected, one or more
fields appear into which static values can be inserted to complete the implied formula.
This provides an ease-of-use option for simple conditions, comparing the contents of the object to the
static values based on the selected operator. For example, if the value of a Status field is equal to “Urgent” or
if a Total Price field is less than zero, the text can be colored red and made bold.
Formula-Driven Conditions
The Formula is condition accepts a totally custom formula that is used to evaluate the condition as Boolean
and then apply the formatting or not.
Once selected, a text area and Specify button appears, as shown in Figure 31-17.
Being completely custom, the formula entered can use any contextual information in its evaluation.
This includes the value of any accessible fields (local or related), global variables, built-in functions, custom
functions, etc.
674
Chapter 31 ■ Manipulating Objects
Figure 31-18. An Invoice list view with conditionally formatted Status field
In this example, the field allows four values; Open, Current, Past Due, and Closed and has the following
conditions:
• An Open invoice will display the status without any additional formatting applied.
This option will not require a condition since the default field format will be used.
• A Current invoice will apply a fill color of green to the status, highlighting the fact
that the money is due but not yet overdue.
• A Past Due invoice will apply a fill color of red to the status, highlighting the fact that
the money is overdue.
• A Closed invoice will color the status text a slightly muted gray, making it less
prominent and emphasizing the fact that the invoice has been paid and is now
inactive.
675
Chapter 31 ■ Manipulating Objects
To configure the last three conditions, select the field on a layout, open the Conditional Formatting
dialog, and configure it as shown in Figure 31-19.
Figure 31-19. The Conditional Formatting dialog configured to apply three different text colors to the Invoice
Status field
676
Chapter 31 ■ Manipulating Objects
■■Note Depending on a field’s Go to next object using settings, typing Return or Enter may perform
the same object stepping action as the Tab key (Chapter 29, “Behavior”).
677
Chapter 31 ■ Manipulating Objects
While in tab-editing mode, each object capable of receiving focus will have a small arrow icon
superimposed attached to one side. These contain the object’s current number in the tab order and are
editable fields. The following actions can be performed in these arrow fields:
• Delete the number to remove the object completely from the tab order. That object
will be bypassed when a user is tabbing in Browse mode.
• Click into a blank arrow field to automatically assign the next available number in
the tab order.
• Edit the number by typing over it. FileMaker will enforce a unique number sequence
by automatically changing the number existing in one arrow if that same number is
typed into another arrow.
3 4 5
Figure 31-21. The Set Tab Order dialog from which tab order can be modified in several different ways for
the entire layout
The following batch functions are available on the Set Tab Order dialog and can make specific changes
across groups of objects on the current layout:
1.
Add Remaining — This combination pop-up menu and button makes available
several functions to add excluded objects into the tab order. Select from the
following options in the menu and click the Add button:
• Objects — This option will add to the tab order all qualifying objects not yet
assigned.
• Fields only — This option will add to the tab order any fields not yet assigned.
• Buttons only — This option will add to the tab order any buttons not yet
assigned.
2.
Remove — This combination pop-up menu and button makes available two
functions to remove objects from the tab order. Select from the following options
in the menu and click the Remove button:
678
Chapter 31 ■ Manipulating Objects
• All fields — This option will remove all fields from the tab order.
• All buttons — This option will remove all buttons from the tab order.
3.
Clear All — This button will automatically delete the tab order from every
object on the layout, providing a clean slate from which you can begin adding
items manually or with the Add Remaining function.
4.
Cancel — This button will close the Set Tab Order dialog and return the
window to standard Layout mode without saving any unsaved changes made to
the tab order.
5.
OK — This button will save changes to the tab order, close the Set Tab Order
dialog, and return the window to standard Layout mode.
Naming Objects
The name property is a unique static text identifier manually assigned to a layout object or group of
objects. Names are optional but become necessary to allow certain functions and script steps to refer
to non-field objects such as portals, tab control, slide control, and web viewers. For example, the
GetLayoutObjectAttribute and Get ( ActiveLayoutObjectName ) functions can only refer to an object
by name. Similarly, the Go To Object, Refresh Portal, and Set Web Viewer script steps require an object
name.
An object name should not be confused with a field name as they are two separate things. An object
name is a property unique to a single object instance on one layout for any type of object. A field name is a
universal definition of a specific data container common to the field on any layout it is placed. An instance of
a field can be assigned an object name different from its defined name, and each instance of the same field
on any layout can have a different object name.
To assign an object name, follow these steps:
• In Layout mode, select an object or a set of grouped objects. Multiple objects not
grouped can’t be assigned a name.
• In the Position group of the Position tab of the Layout Inspector, click into the
Name text area.
• Type a name for the object.
■■Note Object names are not case sensitive and must be unique within the context of a layout. FileMaker
displays a warning dialog if you attempt to enter a name already used by another object on the same layout.
Summary
In this chapter, we discussed various options for manipulating objects on a layout.
679
CHAPTER 32
Text formatting and paragraph settings can be applied to any object directly by selecting the object and
then using options in the Format menu or the Appearance panel of the Inspector. This approach is fine,
especially for beginners working on small database projects with only a handful of layouts. However, as a
project grows, you will want to look for methods to streamline future design changes and improve interface
performance. This can be accomplished by using themes and styles.
In this chapter, we will introduce and define theme and style basics, including the following:
• Introducing themes and styles
• Using themes
• Using styles
Defining Styles
A style is a named collection of various appearance settings for one layout object type.
The functionality of styles can be compared to styles found in word processing, desktop publishing
applications, and cascading style sheets (CSS) with some differences in their accessibility. Styles are similar
in that they can quickly apply consistent formatting to new objects and update the formatting of existing
objects by modifying the settings of a style they share.
However, styles in FileMaker are different in a couple of ways. Since they are a layout design mechanism
used by developers to facilitate efficient layout design, they are not available for user activity when editing the
text contents of a field in Browse mode like they are in word processing and desktop publishing. Also, unlike
CSS and desktop publishing, styles in FileMaker are discrete and cannot inherit attributes from other styles.
682
Chapter 32 ■ Using Themes and Styles
Object
Style
Part Type(s)
States
Format Settings
Figure 32-1. An illustration of the hierarchy defining the groups of multiple format settings that make up a style
Once an object is assigned a style, the interface options reflect choices for two levels of hierarchy above
the format settings: object states and type groups.
683
Chapter 32 ■ Using Themes and Styles
Button Object
State: Normal State: Hover State: Pressed State: Active State: Normal State: Hover State: Pressed State: Active
Format Settings Format Settings Format Settings Format Settings Format Settings Format Settings Format Settings Format Settings
Font Font Font Font Font Font Font Font
Size Size Size Size Size Size Size Size
Style Style Style Style Style Style Style Style
Fill Fill Fill Fill Fill Fill Fill Fill
Border Border Border Border Border Border Border Border
Corner Radius Corner Radius Corner Radius Corner Radius Corner Radius Corner Radius Corner Radius Corner Radius
Alignment Alignment Alignment Alignment Alignment Alignment Alignment Alignment
etc. etc. etc. etc. etc. etc. etc. etc.
Figure 32-2. An example of the number of groups of format settings mandated for a button object
This illustration helps visualize the exponential number of format settings that can be defined for an
object. A button will have eight different groups of format settings since it has two part types, each with four
states.
684
Chapter 32 ■ Using Themes and Styles
Updating Styles
When an object’s format settings are modified, they are not automatically saved back to the assigned style
but are held as unsaved object changes. Any change(s) made to an object must be explicitly saved back to the
style where they will be automatically applied to other objects on the same layout that are assigned the same
style, as shown in Figure 32-3.
This update step only affects object styles on the same layout. To make changes globally, the style must
be saved back to the theme.
Layout 1
Style
Figure 32-3. Format changes only apply to the object affected until those changes are saved to the style
Defining Themes
A layout theme is a single, named collection of styles for various object types used to coordinate styles
uniformly within a layout and across multiple layouts in a single database file. Databases are created with
a group of built-in themes that can be used without modification, with customized, or not at all by using a
custom theme. Professional developers may want to create a robust custom theme with dozens of different
styles for every object type to help them build visually pleasing and consistently formatted interfaces.
Every layout in a database must have a theme assigned. While they can vary from one layout to the next,
to achieve the maximum benefit, a single theme shared by all layouts is recommended.
FileMaker ships with fifty-two built-in themes. Some are rather sophisticated and can provide practical
examples of advanced layout features like the background image slice feature.
Updating Themes
When formatting changes are saved back to a style, they are not automatically saved back to the assigned
theme but are held as unsaved style changes. Any change(s) made to a theme’s styles must be explicitly
saved back to the theme where they will be automatically applied to other objects on any other layout that is
assigned the same theme, as shown in Figure 32-4.
685
Chapter 32 ■ Using Themes and Styles
Automatically updates objects assigned the updated style(s) on other layouts assigned the same theme
Theme
Figure 32-4. Style changes are only saved on the layout upon which they take place until they are saved to
the theme
Remember, this step only updates layouts that are assigned the same theme. So, if every layout in a
database is assigned a single theme, a change to one object type on one layout can be saved back to the
style and then back to the theme to update every single similar object type assigned that style in the entire
database!
■■Caution Since style and theme updates must be explicitly saved, get into the habit of doing so
immediately after any change to an object to avoid a situation where many different unsaved changes are
pending for multiple objects sharing a style.
Using Themes
As new layouts are created, FileMaker will automatically assign the theme it determines best suited for the
new layout type. The somewhat awkward result roughly follow these rules:
• The default layout of a new database will always be assigned the Enlightened theme.
• New Computer layouts will always be assigned the same theme as the layout one is
viewing when beginning the New Layout process.
• New Touch Device layouts will be assigned the Enlightened Touch theme unless
the built-in theme of the layout one is viewing when beginning the New Layout
process has a built-in touch variant. For example, if viewing a layout assigned the
Luminous theme, the new touch layout will be assigned the Luminous Touch theme.
However, if viewing a layout assigned the Cosmos theme, the new touch layout will be
assigned the Enlightened Touch theme.
• New Printer layouts will be assigned the Enlightened Print theme.
Once the new layout is created, you can choose another theme for the layout.
■■Caution You can create custom themes and name them the same as a built-in or custom themes with a suffix
of Touch and Print. However, these will not change the logic of automatic theme assignments listed above and
must be manually assigned to new layouts. FileMaker does not look at custom theme names when determining the
best default assignment for a new layout. All custom themes must be manually assigned to a layout.
686
Chapter 32 ■ Using Themes and Styles
Figure 32-5. The Change Theme dialog window in which a theme can be selected and assigned to the
current layout
The list of available themes is organized in a categorized list with the theme assigned to the current
layout selected. If the database has custom themes defined, they will be listed in a Custom Themes category
at the top of the list.
To change the layout’s theme, select any theme in the list and click OK. The selected theme will appear
in the second row of the toolbar and at the top of the Appearance tab of the Inspector.
When the theme assignment has changed, every object on the layout will be affected in some way
depending on the styles available in new theme compared to those in the old. Some things to consider:
• Objects will retain their assigned style if the new theme has a style with the same
name, changing the format settings as needed. Style names are not case sensitive.
• Any object assigned a style name that is not found in the new theme will be assigned
the Default style for the object’s type from the new theme.
• Most unsaved formatting changes, those applied directly to objects and not saved
back to the style and theme, will be lost during the theme transition.
• However, some unsaved text formatting changes, such as text size, will be retained
when the theme is modified. Other settings like font color and font family will always
change to reflect the corresponding style in the new theme, regardless of their saved
status on the old theme.
687
Chapter 32 ■ Using Themes and Styles
To assist in retaining and reapplying unsaved formatting changes, FileMaker has a rather clever two-stage
undo process for theme changes. Immediately after making a theme change, using the Undo command the first
time will retain the new theme assignment but restore any object attributes that were lost due to being unsaved
in the old theme. Using the Undo command a second time will fully restore the layout to the previous theme with
the previously unsaved modifications still in place. This allows you to assign a new theme on a trial basis, go
back a half step, and then save the previously unsaved changes to the new theme if needed.
■■Tip For the best experience, don’t change themes unless necessary. Choose a theme, duplicate it with
a new name, and use it consistently throughout your database, constantly updating any changes made to an
object. This will help you avoid manually cleaning up a formatting mess after a theme change.
The list of themes in the Choose Theme dialog is not editable and built-in themes can't be deleted from
FileMaker. However, you can duplicate built-in themes and create fully custom themes from the Manage
Themes dialog.
Managing Themes
Themes are managed from the Manage Themes dialog, shown in Figure 32-6, which can be opened by
selecting the File > Manage > Themes menu item. As you assign themes to layouts, they are added to this
dialog.
2 3 4 5 6 7
688
Chapter 32 ■ Using Themes and Styles
2.
Import — This button begins the process of importing custom themes from
another database file.
3.
Rename — This button opens a dialog allowing you to rename a custom theme.
Built-in themes in the list can't be renamed; however, a built-in theme can be
duplicated and renamed to create a custom theme.
4.
Duplicate — This button allows you to duplicate the selected theme. The new
theme will have the same name as the selection with the word “Copy” added as a
suffix. It can then be renamed if desired.
5.
Delete — This button allows you to delete themes listed above that are no longer
assigned to any layouts. If you attempt to delete a theme that is currently in use,
an error dialog will be presented informing you of this fact.
6.
Cancel — Click this button to close the dialog without saving any changes to the
theme list.
7.
OK — Click this button to save changes and close the dialog.
Using Styles
As an object is added to a layout, Filemaker automatically assigns it the Default style based on the type of
object from the layout’s theme. This style assignment can be changed to a different existing style or saved as
a new style. As styles are created, deleted, and modified, these changes must be saved back to the Theme to
update other layouts using the same theme.
Figure 32-7. The two methods by which to assign a new style to a selected object
Once the change is made, all the appearance and format settings for every state of every part of the
object will be updated to reflect the settings defined by the style.
689
Chapter 32 ■ Using Themes and Styles
690
Chapter 32 ■ Using Themes and Styles
5.
Choose one of the following theme actions from the menu:
• Revert Changes to Theme —this option will eliminate all the unsaved changes
made to any style on the current layout, restoring every object’s format settings
to those last saved to the theme.
• Save as New Theme — this option will leave the current theme unchanged and
save a copy of all its styles into a new theme, which you name as part of the
process.
• Save Changes to Theme — this option will update the current theme with all the
saved styles. This, in turn will update the format settings of all objects on every
layout that shares the same theme.
Summary
In this chapter, we discussed the basics of using themes and styles to improve the efficiency of the interface
design process and the performance of layout rendering.
691
CHAPTER 33
Customizing Menus
One of the most powerful capabilities of the FileMaker Pro Advanced application is the ability for developers
to customize the menu bar and gain total control over the application experience.
In this chapter, we explore this powerful capability, covering the following topics:
• Exploring the capabilities of custom menus
• Getting started with custom menu basics
• Exploring the manage custom menus dialog
• Creating a custom menu set
• Customizing menu items
• Installing a menu set
• Exploring the link between commands and menus
• Creating status-based custom menu
The menu customization feature allows you to define multiple sets of menus so that, in an extreme
example, every layout could have a completely unique set of menus for each user group if necessary.
Menu Bar
Submenu
Submenu
Separator
The menu bar is the horizontal strip running along the top of the screen (macOS) or the top of a
database window (Windows) that displays the currently active menu set.
A menu set is a named collection of menus that can be installed into the menu bar, becoming the
active menu set. Every database starts with one non-deleteable and non-modifiable default menu set called
[Standard FileMaker Menus], but developers can create custom menu sets to be installed in place of the
standard set all the time or depending on the layout, user or other conditions. The various resources that
make up a menu set can be illustrated in a hierarchical structure, as show in Figure 33-2.
694
Chapter 33 ■ Customizing Menus
Menu Set
Menus
Menu Items
A menu is a list of menu items grouped together under a single title, which appears in the menu bar.
A menu item is an item contained in a menu with properties defined by the assignment of one of three
available types:
• A command is a menu item that triggers specific functionality: either a standard
command or a custom script. These may be assigned a key command to provide
a shortcut for triggering the associated function directly from the keyboard.
Key commands can be configured using any single alpha-numeric key and a
combination of the Shift, Option/Alt, and/or Command/Windows key(s) to form
a unique keystroke for triggering a menu item, but only if that combination isn’t
reserved by the operating system or some other menu item.
• A submenu is a menu item with an arrow icon that, when selected, reveals a secondary
menu of options subsumed under it. Submenus are useful in helping to delimit menu
commands into categorized groups and avoid overwhelming the user with too many
options in a single list. They can be nested so that a submenu can include item(s) that
open another submenu that includes item(s) that open another, etc.
• A separator is a horizontal line used to separate groups of menu items to create a
more visually productive organization of items.
Menu items that perform a command can be enabled or disabled based on a user’s access settings.
They can also be installed or not based on a formula.
Standard menu items are either selection based, where a click temporarily highlights the item and
performs a function, or they can be status based, where a click toggles a check mark next to the item name to
indicate it is “on” or “off.” Custom menus can only be selection based. However, a menu can use a calculated
name that can toggle between two (or more) status modes, which can simulate a status-based menu item
(see example at the end of this chapter).
695
Chapter 33 ■ Customizing Menus
• Any of eight standard FileMaker menus that can be copied and customized as
needed (with a few exceptions): FileMaker Pro, File, Edit, View, Insert, Records,
Request, and Help.
• A choice of about two dozen submenus found in standard menus, which can be
attached to the menu set as a stand-alone menu with its standard non-editable
menu. These include submenus such as Open Recent, Import Records, Go to
Layout, Manage, Sharing, Show Window, and more.
There are many different approaches available to design a custom menu set depending on a database’s
requirements. A custom set may begin as a duplicate of the entire standard FileMaker menu set, which is
then customized, a totally empty set that is built from scratch, or some combination of these two.
Figure 33-3. The absolute minimum menu bar when a custom menu set is installed with no menus defined
The following menus will always be visible, even for a completely empty custom menu set:
• Apple (macOS only) — This menu contains standard operating system functions and
is completely unaffected by the custom menu set and can’t be modified in any way.
• FileMaker Pro — The application menu will always be present in the menu bar
regardless of it being present in a custom menu set. However, the exact configuration
of this menu will vary as follows:
• The top portion of the menu — the About FileMaker Pro item and first divider
line — are only present if a copy of the menu is added to the custom menu set
and left unmodified.
• The remaining portion of the menu is always present in the menu bar regardless
of a copy of the menu being present in the set or not. Also, these items are not
shown when editing a copy of the menu in a custom menu set and, therefore,
they can’t be removed or customized in any way.
• Tools — This menu is exclusive to FileMaker Pro Advanced, is always included in the
menu bar, and can’t be added to a custom menu set or modified in any way.
• Help — The application menu will always be included in the menu bar regardless
of its being present in a custom menu set. However, the exact configuration of this
menu will vary as follows:
• The top portion of the menu — the Search field — is always included in the
menu bar regardless of a copy of the menu being present in the custom menu
set or not.
• The remaining items in the menu are only present if a copy of the menu is
added to the custom menu set and they are left unmodified.
696
Chapter 33 ■ Customizing Menus
Figure 33-4. The common elements of both tabs of the Manage Custom Menus dialog
Both tabs of the Manage Custom Menus dialog contain the following controls:
1.
Tabs — The dialog is divided into the following two tabs, each containing a list
of one type of menu-related entity that can be managed with the other common
elements:
• Custom Menu Sets
• Custom Menus
2.
Item List — The central area on each tab contains a list of all the items defined.
These can be sorted by clicking on column headings or using the View by menu.
3.
List Buttons — Four buttons provide control over the list of items:
• Create — Click to begin the process of adding a new item to the list.
• Edit — Click to open the selected item in an Edit dialog.
• Duplicate — Click to duplicate the item(s) selected in the list.
• Delete — Click to delete the item(s) selected in the list.
697
Chapter 33 ■ Customizing Menus
4.
Sort menu — The View by pop-up menu contains the available options for
sorting the list of items.
5.
Default menu set — The Default menu set for this file pop-up menu contains
a list of all menu sets defined. The selection will become the default for the file at
startup and for any layout configured to use the [File Default] menu set.
6.
Dialog Buttons — Three buttons provide control over the dialog:
• Update — Click to add any missing menus to the database when the database
is upgraded from a very old version of FileMaker, which may be missing some
newer items.
• Cancel — Click to close the dialog without saving changes to the menu
definitions.
• OK — Click to save changes to the menu definitions and close the dialog.
■■Caution All the functions of the Custom Menus tab can also be accessed through subsequent dialogs
opened from the Custom Menu Sets tab. This redundancy provides more direct access to individual custom
menus but be confusing at first.
698
Chapter 33 ■ Customizing Menus
4.
Enter a name into the Menu Set Name text area, for example, Learn FileMaker
Menus, as shown.
5.
The Comment area is used to enter developer-only notes about the menu set being
defined. For example, this can contain information about the purpose of the
menu set or the conditions for when it will be used.
■■Caution The process of adding standard menu items to a custom menu set is done two different ways
and can be a little confusing. Three standard menus can be added directly from the default selection of menus
on the Select Menu dialog. The remaining eight must be first copied into that list of available menus and then
added to the set. This additional step is explained in the process to follow.
699
Chapter 33 ■ Customizing Menus
Figure 33-6. The Select Menu dialog lists all available standard and custom menus
The Select Menu dialog contains a list of every standard menu, standard submenu, and custom
menu defined within the database file. For a new database without any custom menus yet defined, the list
will contain only the three standard menus that can be added without customization as well as the other
submenus that can be added as a menu.
To continue, hold down the Command key to allow for multiple selections, then click on the three
standard menus in the list: [Format], [Scripts], and [Window]. Once selected, click the Select button to
add the three selected menus to the custom set.
Next, to add the remaining standard FileMaker menus to the custom set, we need to create a copy of the
menu by once again clicking the Add button on the Edit Custom Menu Set dialog and then clicking the +
button on the Select Menu dialog. This will open the Create Custom Menu dialog, shown in Figure 33-7.
700
Chapter 33 ■ Customizing Menus
Figure 33-7. The Create Custom Menu dialog is used to create a new menu
The Create Custom Menu dialog allows the choice of two options for the new menu we are adding to the
list of available menus:
• Start with an empty menu — Creates a new unnamed menu with no menu items.
• Start with a standard FileMaker menu — Creates a copy of a selected standard
FileMaker menu, which can be further customized as needed.
Add each of the eight standard menus listed, one by one, by selecting them and clicking OK. For each,
the new menu will be created and opened in the Edit Custom Menu dialog. For now, just click OK in that
dialog to save the new menu copy. Once finished, the Select Menu dialog should contain a list of all eight
copies of the standard menus, shown in Figure 33-8.
701
Chapter 33 ■ Customizing Menus
Figure 33-8. The Select Menu dialog after creating a copy of every standard FileMaker menu
■■Tip FileMaker will automatically name each copy of a customizable standard menu with a suffix of “Copy”
as shown in Figure 33-8. If you don’t rename them as you create them, be sure to do so later. It’s always a good
idea to add a common prefix to the beginning of each custom menu just to help differentiate them apart from
the other non-customizable submenus in the list and to integrate them together into a group.
Holding the Command (macOS) or Windows (Windows) key, select all eight of the standard menu
copies and click the Select button. This will return to the Edit Custom Menu Set dialog, showing a list of all
eleven standard menu items, shown in Figure 33-9.
702
Chapter 33 ■ Customizing Menus
Figure 33-9. All the standard FileMaker menu items added to the custom menu set
Depending on the order in which the menus were selected and added to the custom set, they may
not be in the correct order, as shown in Figure 33-9. Menus can be dragged and dropped within the list to
reorder them with the following two exceptions:
• The FileMaker Pro menu will remain locked as the first in the list.
• The Help menu will remain locked as the last menu in the list.
Once the menus are in the desired order, click OK to save the changes and close the Edit Custom Menu
Set dialog. Then click OK to close the Manage Custom Menus dialog. Now you can manually install the
custom menu set by selecting it from the Tools > Custom Menu menu, shown in Figure 33-10.
Figure 33-10. Select the custom menu set to install it as the current menu
When the custom menu set has a check mark next to its name in this menu, it is installed. If everything
worked correctly, you should notice no differences between the current menus compared to the standard
FileMaker menus. Now you are ready to begin customizing the new menu set.
703
Chapter 33 ■ Customizing Menus
1
2
3
5 7
6 8
704
Chapter 33 ■ Customizing Menus
3.
Menu Title — This set of controls allows specification of the menu title that will
be visible in the menu bar. If the menu is a copy of a standard FileMaker menu, a
Default option will be available to use the standard name. To override this or to
enter a name for a custom menu, the Override Title area contains a text area
to type in a name and an Specify button to open a dialog in which you can enter
a formula to dynamically calculate a name. Custom menu names can be up to
30,000 characters in length; however, due to the practical limitation of the width
of a screen (macOS) or a database window (Windows), as well as the nature of
human perception, it is best to limit each menu name to a single word.
4.
Install Settings — This area controls when a menu is installed in the menu
bar using one of two sets of controls that work in concert:
• Install when — this text area can contain a static Boolean value of 1 or 0 to
control if the menu will be installed. The adjacent Specify button will open a
Specify Calculation dialog into which a formula can determine the Boolean.
• Include in mode — these check boxes allow a quick selection of which mode(s)
the menu will appear.
5.
Menu Items — This area contains a list of every item that makes up the menu.
Reorder items by dragging them up and down within the list. Select an item to
edit it in the adjacent Menu Item Settings area.
6.
Menu Item Buttons — These buttons are used to manage menu items in the list:
• Create — Click to insert a new menu item below the current selection.
• Duplicate — Click to duplicate the selected menu item(s) in the list.
• Delete — Click to immediately delete the selected menu item(s) in the list.
7.
Menu Item Settings — This area contains all the settings relevant to the selected
menu item based on the Menu Item Type selected in the pop-up menu at the top
of the area. These will be explored in the next section.
8.
Menu Buttons — These buttons control whether changes to the menu are saved
when closing the dialog. Click Cancel to close the dialog without saving changes.
Click OK to save changes and close the dialog.
■■Note The Install when option is the only option available for Separators.
705
Chapter 33 ■ Customizing Menus
2
3
4
706
Chapter 33 ■ Customizing Menus
Figure 33-13. The Specify Shortcut dialog in which a typed shortcut is captured for storage on the menu
item profile
4.
Action — Enable this box to assign a script or script step to the menu item.
If the menu item is based on an existing command, the selected script or step
will override that command’s functionality. To reassign a different action, click
the Specify button.
707
Chapter 33 ■ Customizing Menus
Many other menu items, especially those in the Records menu can benefit from a conditional name that
includes the name of the table, making clear which records will be affected by the command.
708
Chapter 33 ■ Customizing Menus
To remedy this, a script using a Show Custom Dialog step (Chapter 35) can present any number of more
specific confirmation prompts, including:
• Permanently delete this entire CONTACT record?
• Permanently delete the CONTACT record for John Smith?
• Permanently delete the CONTACT record for John Smith? This will also
delete all email correspondence and call logs.
Any of these prompts would help to avoid the hypothetical scenario described above.
Once you have established the desired message formula, create a script that performs the steps to ask
the user, evaluate their response, and take the appropriate action or not. For example:
This script presents a detailed dialog message asking the user to confirm the record deletion request.
The index of the button they click is placed into the $Button variable and the script is either exited if they
clicked Cancel or the Delete Record/Request is performed if they clicked Delete.
Once written and tested, override the Delete Record menu item’s Action to point to your script.
Case (
Get ( AcccountPrivilegeSet ) = "[Full Access]" ; 1 ;
0
)
709
Chapter 33 ■ Customizing Menus
The standard Scripts menu can be used for this function; however, sometimes it is beneficial or
desirable to create one or more custom menus to provide a more professional solution.
For example, a database with dozens of predefined search scripts that find groups of records in different
tables by status or other criteria could be placed under the Records. Similarly, report scripts for invoices and
other tables could be placed under the File menu near the Print item. However, in both cases, the custom
menu items would be somewhat at a disadvantage. They would add clutter to already crowded menus and
would require a user to know all the various locations in which to access these custom scripts.
Adding new menus solves these problems. The exact arrangement will vary depending on the number
and variety of functions requiring a presence in the menu. Using the previous example, with a large
quantity of search and report scripts, a developer may add two menus: Searches and Reports. However, if
the number of items in each is sparse or these are two among dozens of potential new menus, one might
consider adding a single menu called Actions and having each category be a submenu within.
FileMaker Pro Advanced File Edit View Insert Format Records Scripts Actions Tools Window Help
Figure 33-16. The new empty Actions menu added to the menu bar
710
Chapter 33 ■ Customizing Menus
■■Tip Since human perception begins to reach capacity for efficient processing of information at about 5-9
objects, use the “rule of about seven” to determine when to divide menu items into groups using separators or
submenus. Try to integrate small groups of similar items together and differentiate them from other groups by
either method of division.
711
Chapter 33 ■ Customizing Menus
To create a submenu, first create a custom menu containing the items that will be available in the submenu.
This menu will not be added to the menu bar directly, but will be added to a menu as a submenu item.
For example, create new custom menu called Reports Submenu and add one menu item for each
report script. Then, open the Actions menu and create a new item named “Reports…” and configure it as a
submenu pointing to the Reports Submenu, as shown in Figure 33-18.
After stepping back out of the dialogs saving as you go, the Actions menu should now display a Reports
submenu, like that shown in Figure 33-19.
712
Chapter 33 ■ Customizing Menus
Menu Item
Privilege Permissions
Toolbar Icon
Command
Contextual Menu
Figure 33-20. Three instances of the New Record command in the standard FileMaker interface
713
Chapter 33 ■ Customizing Menus
Ultimately, each of the interface elements points to the command that is performed when they are
clicked. This connection provides the name and tooltip for the elements and runs through the security
settings to determine the accessibility of the command for the current user. The visibility or enabled state
of the interface elements is controlled by two factors. The interface element will be visible or enabled only if
both conditions are true:
• The command is present in the current menu bar.
• Access to the command is permitted through the user’s security settings.
The interconnection of these interface elements must be taken into consideration when using custom
menus and can be illustrated abstractly as shown in Figure 33-21.
Permissions
enable / disable command
Command
Figure 33-21. An illustration of the interconnection between a command, menu, and other standard interface
elements
The elements across the top of this illustration are the visual interface manifestations of the command
at the bottom. Notice how they each pull various properties from either the command, the intervening user
permissions, and from either a default or a custom menu set. Each element will be affected as follows:
• Menu Item — will get its name from either the default or custom menu set; its
enabled status from a combination of its menu settings and the privilege set defining
the user’s permissions to the command it represents.
• Contextual Menu Item — will be visible in the interface only if the command is
represented and enabled in the active menu bar; gets its name from the menu item,
which comes from from either the default or custom menu set.
• Toolbar Icon — will be enabled only if the command is represented and enabled in
the active menu; gets its name and tooltip from the menu item, which comes from
either the default or custom menu.
714
Chapter 33 ■ Customizing Menus
When customizing the standard New Record menu item, assigning it a new name and configuring it to
perform a custom script, that menu item will remain linked to the command. Therefore, the menu item will
continue to enable or disable based on the current user account permissions. It will also update the custom
name in the menu, the contextual menu, and toolbar, and each of these will now perform the custom script.
For example, if the New Record menu is renamed New Sheet and a custom script is assigned, both the
toolbar button and contextual menu will change to display this name, as shown in Figure 33-22, and perform
the custom script rather than the default New Record function.
Toolbar Button
Contextual Menu
Figure 33-22. The result of renaming the New Record command in a custom menu
However, if the New Record menu item is deleted from the custom menu set and new blank menu
item is added to handle new record creation, it will not automatically be linked to the command, Therefore,
the new menu item will not automatically enable and disable based on permissions and its presence in
the menu will not pass properties to the toolbar button or contextual menu, resulting in these becoming
disabled or invisible. This is true even if the new menu item is assigned the standard name of New Record.
For a new menu item to act as the hub of interface elements described above, it must be explicitly
assigned to the command using the Based on existing command settings in the Edit Custom Menu dialog,
as shown in Figure 33-23.
Command
Figure 33-23. A custom menu must be explicitly linked to a command to react to permissions and enable and
name other interface elements
715
Chapter 33 ■ Customizing Menus
A command menu item’s relationship to a standard command can take one of three ways:
• Standard Command Only — When linked to a standard command without a name
or script override, the menu will appear and perform the normal functionality
associated with the command and influence other interface elements normally.
• Script Only — When not linked to a standard command and assigned a custom
name and a script, the menu will perform the script as its function and any other
command-related interface elements will be disabled or invisible.
• Both Standard and Script — When linked to a standard command with a name or
script override, the menu will appear and perform a script based on the custom
settings and will be linked back the standard command for permission and influence
other interface elements similarly.
It is vitally important to understand this method of integration to provide users with access to the full
range of built-in tools and convenience when customizing naming or behavior.
Figure 33-24. The View menu has several status-based menus, denoted with a check mark when active
Some status-based menu items can allow multiple choice status menus, where there are more than two
options. For example, one of the four available modes at the top of the View menu will always have a check
mark next to it indicating it as the active window mode. Similarly, one of the three View as options will be
marked indicating the window view type selected for the active window.
716
Chapter 33 ■ Customizing Menus
Other status-based menus are a single menu indicating a setting as being on or off. For example, the
Status Toolbar menu item displays a check mark when the toolbar is visible and no check mark when it is
not visible. The single menu item can be selected to toggle this choice back and forth.
When using custom menus there is no a built-in option to make one or a set of menu items status based,
and there is no way to include a check mark in the proper position to simulate such a state. However, there is
a technique available to approximate a status-based menu where the name of the menu changes to indicate
the status. Since a menu item’s name can be the result of a calculation, it is possible to have the name change
to indicate the current state and create a toggle effect each time a user selects the item.
A menu item might alternate between two names: Enable <Mode> and Disable <Mode>. This can be
accomplished using a global variable to store the current state. The menu item’s name calculation looks to
the global variable to alternate the name while other resources or scripts looks at the global to determine
whether the mode is active or inactive. The script assigned as the menus action toggles the global variable,
which changes the state and the menu item’s name.
Working through an example, let’s create a menu item that allows users to control whether tooltips on
layout objects will be displayed or suppressed. This is a practical example since new users will tend to need
tooltips to guide them but more experienced users might find them annoying. So, imagine a single menu item
that will toggle between Enable Tooltips or Disable Tooltips implemented by following these steps:
• A global variable named $$Mode_Tooltips will be initialized to a value of 0 by an
OnFirstWindowOpen script trigger. This will indicate that the tooltips feature is “off”
by default when the database file opens.
• Every layout object that has a tooltip will check this variable to determine if it should
or should not display a tooltip, using this formula:
• A custom menu item, perhaps under the File menu or elsewhere, will use a Name
formula that determines a name based on the opposite of the current state. If the
global variable has a value of 0 indicating tooltips are off, its name will be Enable
Tooltips; if the global variable has a value of 1 indicating tooltips are on, its name
will be Disable Tooltips, using this formula:
• The custom menu item will run a script that toggles the value of the $$Mode_
Tooltips variable, using this formula:
Case ( $$Mode_Tooltips = 1 ; 0 ; 1 )
Now, when the user selects Enable Tooltips, the global variable is assigned a value of 1, and tooltips
begin appearing whenever they hover the cursor over objects and the custom menu item’s name changes to
Disable Tooltips.
Summary
In this chapter, we introduced the menu customization options available with FileMaker Pro Advanced to
take full control of the application experience.
717
PART V
Introduction to Scripting
FileMaker has extensive scripting capabilities, making possible a richly interactive interface with
automation-assisted functionality. Tables store information; layouts display information; and scripts
navigate, analyze, manipulate, repurpose, and share information.
A script, sometimes called a macro, is a developer named and assembled sequence of customizable
action steps that are stored for later execution. Scripts can perform simple tasks like navigating, searching,
sorting, and inserting. They can perform complex tasks that manipulate or compile information from
numerous fields across founds sets of records from multiple tables. They can even be integrated across
multiple database files. Any repetitive, non-creative, logically definable task that a person can perform
manually within a database, a script can perform automatically.
In this chapter, we will introduce scripting, covering the following topics:
• Identifying the benefits of scripting
• Exploring script basics
• Exploring the script editor interface
• Writing scripts
■■Note The number of scripts in a file is limited by disk space. The number of scripts that can be displayed
in the Scripts menu is 512 on Windows and 32,767 on macOS.
• Refocus on Quality — By freeing users from onerous procedural details that can be
encoded into a script and reproduced automatically, users are free to focus more
effort on improving the quality of their work.
• Improved Performance — Scripts run without any hesitation so they can perform
complex tasks much faster than a person. For added benefit, when a database is
hosted on a FileMaker Server, scripts that don’t require user input and don’t care
about the current context can be run on the server, thereby offloading the task away
from the user’s computer, freeing their workspace for manual work.
• Scheduled Automation — When used with a FileMaker Server, scripts can be
scheduled to run automatically on a schedule. This means that maintenance
functions can be automatically triggered at night or on weekends, without any
intervention from users.
Event Schedule
Button Menu FileMaker Script OS Script FileMaker URL
(Script Trigger) (FileMaker Server)
Script Runs
(Optionally Receiving a Parameter)
Performs Actions
Access Tables & Fields
Navigate to Layouts
Perform Other Scripts
Generate Output
Etc.
Figure 34-1. The script flow: an object or event runs the script, which, performs actions and optionally returns
a result
722
Chapter 34 ■ Introduction to Scripting
Figure 34-2. The Perform Script step and Specify Script dialog are used to instruct a script to run
another script
■■Note The Specify Script dialog was explored in detail in Chapter 30, “Configuring a Button to Perform a
Script.”
723
Chapter 34 ■ Introduction to Scripting
Script 2
Script 3 Script 4
Figure 34-3. An illustration of a script calling other scripts, both directly and in a stack
The ability of a script to run other scripts and exchange data back and forth, allows scripts to be more
delimited and less monolithic. Instead of building one massive script that performs dozens or hundreds of
steps, the process can be broken into separate scripts, each focused on a certain task. This allows scripts to
be designed like subroutines or functions in object-oriented programming languages. It makes it possible
to setup a hierarchy where some scripts perform open-ended, fundamental tasks that can be shared by
many other scripts regardless of context, some managing the top-level process for a specific layout, and
others somewhere in between.
Script 1
<parameter> <result>
Script 2
Figure 34-4. An illustration of a script pushing a parameter to a sub-script and then receiving a result
724
Chapter 34 ■ Introduction to Scripting
to reach out and pull in information, a script parameter allows the triggering object to push in information so
that it can vary from one run request to the next. Using parameters allows scripts to be written in a flexible,
open-ended way with some or all the functionality being controlled or fed information from the triggering
object or event.
A simple example to illustrate the use of parameters is a script that displays a dialog. The information
can be hard-coded into the script’s Show Custom Dialog step or it can be pushed in as a parameter, allowing
each calling object to provide a unique message, as illustrated in Figure 34-5. In this example, clicking either
button would display a different message even though they are running the same script.
Button Button
Figure 34-5. An illustration of a simple script parameter changing the message the script will display in a dialog
Admittedly, this example is far too simplistic to adequately demonstrate the full power and benefit of
using parameters. The data transmitted as a script parameter can vary in complexity as needed, including
any of the following:
• A single word.
• A sentence.
• A field reference.
• A list of paragraphs carriage return-delimited values containing a mixture of raw
information or instructional commands.
• A JSON object containing an array of key/value pairs containing structured
information.
The script receiving parameters must be explicitly programmed to access the input using the
Get ( ScriptParameter ) function. If multiple values are received, it must parse the data into the
appropriate variables.
Although there is only one script parameter, it can take the form of a carriage return-delimited list
to accommodate multiple values. When using this technique, it will be necessary for the receiving script
to parse the values into separate variables. They can be parsed any number of ways depending on the
circumstances.
725
Chapter 34 ■ Introduction to Scripting
If there are a fixed number of values, a Let statement can use a sequence of GetValue functions to
parse out each value and place it into a variable. If the number of values varies, a Loop statement might be
necessary to extract them one by one. For more complex situations, consider a structured format such as the
JSON object, which can be easily parsed and manipulated (Chapter 14).
■■Caution Other methods of exchanging data between scripts includes the use of global variables or
global fields. For a single exchange of information between two scripts, script parameters are the best
recommendation. Global variables can be used and are often justified, but these should be limited to situations
where the data is needed on a global scale. Using global fields for this purpose is dated, having become
obsolete with the introduction of global variables and parameter passing.
An Exit Script step can be placed in multiple positions within the script workflow, each returning
a different value. For example, after performing a find, a conditional If statement can exit the script if no
records are found. In that case, the resulting string can vary to indicate what functions were or were not
performed, as shown in this example:
Perform Find [ ]
If [ Get ( FoundCount ) = 0 ]
Exit Script [ Text Result: "No records found" ]
End If
Loop
<steps to process records>
End Loop
Exit Script [ Text Result: "Success" ]
726
Chapter 34 ■ Introduction to Scripting
The context of the local computer’s database window will not be known or accessible to the server.
Therefore, any information about the current table, layout, record, found set, sort order, or window required
by the script being called must be sent to the script as a script parameter so the server can replicate
the context or process using the information provided about the context. New scripts can be designed
specifically to address this issue. When converting an existing script to run on the server, it may be necessary
to split it into two: one script that loads the context information into a script parameter and another that will
receive that information and can safely run on the server.
If the script is critical to the database functioning normally at launch, it is a good idea to include an If
statement to allow the script to be run on the server during normal operations but locally when the database
is not hosted. For example, if you take the databases offline and open them in a copy of the client software
for troubleshooting, maintenance, or migration to a newer version, you don’t want to be struggling with a file
that won’t open properly because of scripting errors. This example demonstrates an If statement choosing
between running the script locally or on the server with the help of a built-in function:
■■Caution The Perform Script on Server step should not be confused with running a scheduled script on
the server. The former is used by a script running locally on a client to request a script be run on the server; the
latter is triggered by a scheduling mechanism on the server software and does not invovle a client.
727
Chapter 34 ■ Introduction to Scripting
2 4
Figure 34-6. The Script Workspace dialog in which scripts are created and managed
Once open, the workspace window has standard operating system controls for minimizing and closing.
The dialog is divided into the following four sections:
1.
Workspace toolbar
2.
Scripts pane
3.
Script editor
4.
Script steps pane
728
Chapter 34 ■ Introduction to Scripting
Workspace Toolbar
The script workspace toolbar of the Script Workspace dialog, as shown in Figure 34-7, is a static toolbar
containing a handful of buttons used to create, edit, debug, and run scripts.
2 3 4 6
Figure 34-7. The Script Workspace dialog toolbar contains several static function buttons
Script Pane
The scripts pane of the Script Workspace dialog, shown in Figure 34-8, displays a list of every script defined
in the database file. Here scripts can be renamed, rearranged, and organized into a folder hierarchy.
729
Chapter 34 ■ Introduction to Scripting
3 5
1
6
2 7
8 9
730
Chapter 34 ■ Introduction to Scripting
7.
Scripts — a script is represented in the list by a small script icon and name.
There are several ways to interact with a script:
• A click will select the script and temporarily display its contents within the
editing pane.
• A second single-click will allow editing of the script name.
• A double-click will lock the script in editing mode within the editing pane even
though no changes have been made.
• The script’s contextual menu contains a subset of functions from the
Scripts menu.
8.
Separator Line —a separator line is used to divide groups of scripts. These can
be dragged up or down the list to help visually divide groups of scripts or folders.
9.
Unsaved Change Indicator — scripts open with unsaved changes display this
asterisk icon.
Script-Editing Pane
The central script-editing pane of the Script Workspace dialog, shown in Figure 34-9, displays the selected
script and is used to view or edit the steps that make it up. Scripts are automatically opened into tabs making
it easy to jump back and forth between multiple scripts; however, they can be moved into separate windows.
3 4
731
Chapter 34 ■ Introduction to Scripting
• Rename Script — makes the script name editable within the tab. You can also
double-click on the tab to edit the name.
• Check for Problems — highlight in red any script steps within the script that
have a detectable problem. The feature can’t be turned off manually but will
reset when a tab is closed.
• Close Tab — close the tab after a warning to save any changes.
2.
Script Steps — each line of a script represents one script step and is displayed
in a scrollable area with automatic numbering.
3.
Unsaved Change Indicator — asterisk icon appears next to a script with
unsaved changes.
4.
Preview Mode Indicator — icon will appear when a script is open in a
“quick view” state and no changes have been made. In this case, the open script
is displayed temporarily and selecting another script will replace it. Three actions
will cause a script to be retained until explicitly closed:
• Open the script and click the Preview Mode Indicator
• Double-click on the script in the list
• Editing the script
■■Tip Starting in FileMaker Pro 16, script tabs can be reordered by dragging them around in the tab bar.
Also, when using the Perform Script step, clicking on the selected script name in the statement while holding
the Command (macOS) or Windows (Windows) key will automatically open the script into a new tab!
732
Chapter 34 ■ Introduction to Scripting
Figure 34-10. The Scripts Steps Pane of the Script Workspace dialog provides access to every available
script step
The following function buttons are available in the Scripts Step Pane:
1.
Search Filter — enter text in this area to filter the list of script steps to include
only those whose name contains the value entered.
2.
Category — when viewed in hierarchical order, every script step is grouped
under a category, which can be opened and closed by clicking the disclosure
triangle on the left.
733
Chapter 34 ■ Introduction to Scripting
3.
Script Steps — lists all the available steps, displayed alphabetically or
hierarchically, optionally filtered to only those that match the search criteria
entered. The step’s contextual menu contains the following functions:
• Insert Into Script — insert the script step into the script. This can also be
accomplished by double-clicking on the step.
• Add/Remove Favorites — toggle between adding and removing the step to
favorites.
• Lookup In Documentation — open the FileMaker help guide for the script step.
4.
Help Guide Hint — displays a brief description of the selected script’s function.
Open the full help guide by clicking the help icon on the right.
5.
Favorites Toggle — adds or removes the selected script step from the favorites
category, which is displayed at the top when viewing steps hierarchically. The
icon will be gray when a selected step is not listed in favorites and blue when it
has been assigned.
6.
View Toggle — toggles the list of script steps between the hierarchical and the
alphabetical view.
Edit Menu
The Edit menu, when working in the Script Workspace, contains a modified unique set of functions, as
shown in Figure 34-11.
734
Chapter 34 ■ Introduction to Scripting
Figure 34-11. The Edit menu when working in the Script Workspace
In addition to standard Edit menu functions such as Cut, Copy, and Paste, the following new functions
are available when working with scripts:
• Undo <last task> — reverses the last change to a script step within the current
script window. The menu updates to indicate the type of change that will be
reversed. For example, it might say Undo Reorder, Undo Create, or Undo Delete.
• Duplicate Step — create a duplicate of the selected script step(s).
• Disable — toggle the enabled/disabled status of the selected script step(s).
View Menu
The View menu, when working in the Script Workspace, contains a completely unique set of functions, as
shown in Figure 34-12.
Figure 34-12. The View menu when working in the Script Workspace
735
Chapter 34 ■ Introduction to Scripting
The functions available in the View menu are also accessible through buttons and contextual menus
within the dialog:
• Show/Hide Scripts Pane — toggle the visibility of the Scripts Pane on the left side
of the dialog.
• Show/Hide Steps Pane — toggle the visibility of the Steps Pane on the right side of
the dialog.
• Show/Hide Step Description Pane — toggle the visibility of the Step Description
Pane at the bottom right of the dialog.
• Show/Hide Scripts Menu Management — toggle the visibility of the row of check
boxes to the left of the scripts name in the Scripts Pane.
• Close Tab — close the current script tab after a save warning, if required.
• Close All Tabs — close every open script tab after a unified save warning, if
required.
• Close Workspace — close the Script Workspace dialog after a unified save warning,
if required for any open scripts. Any scripts that are left open when closing the
workspace will remain in place the next time the workspace is opened.
• Select Next Tab — select the tab to the right of the current selection.
• Select Previous Tab — select the tab to the left of the current selection.
• Move Tab to New Window — open the current tab's script in a new dedicated
window to allow side-by-simultaneous-side editing of scripts.
• Compatibility — opens a submenu with a list of device and software platforms.
To see which script steps are compatible with a specific platform, select it from the
menu. Any incompatible script step will be formatted in gray text.
• Script Workspace Preferences — opens a small dialog that contains preferences
specific to the Script Workspace dialog. From here you can control whether new
scripts are automatically visible in the Scripts menu and control the syntax coloring
of steps within the script workflow.
Scripts Menu
The Scripts menu when working in the Script Workspace contains a completely unique set of functions, as
shown in Figure 34-13.
736
Chapter 34 ■ Introduction to Scripting
Figure 34-13. The Scripts menu when working in the Script Workspace
The functions available in the Scripts menu are, with a few exceptions, also accessible through buttons
and contextual menus within the dialog:
• New Script — create a new script.
• New Folder — create a new folder in the Scripts pane.
• New Separator — create a new separator line in the Scripts pane.
• Import — open a dialog to begin the process of importing scripts from another
FileMaker database file.
• Open Script in New Tab — open the selected script in a new tab.
• Open Script in New Window — open the selected script in a new window.
• Rename Script — allow editing of the script name directly from the Scripts pane.
• Duplicate Script — create a duplicate of the selected script.
• Delete Script — delete the selected script after a warning dialog.
• Include/Exclude in Scripts Menu — toggle the check box that controls if the
selected script appears in the Scripts menu.
• Grant/Revoke Full Access Privileges — toggle the setting for the selected script
that allows it to run with full access privileges even when the current user does not
have full access. This allows you to maintain stricter limitations on what a user can
do manually within the interface while still allowing scripts to function without
restrictions. When a script has been granted full access, a small icon of a person
appears next to its name in the Scripts pane.
• Run Script — execute the current script.
737
Chapter 34 ■ Introduction to Scripting
• Debug Script — execute the current script to execute with the Script Debugger
automatically turned on.
• Save Script — save changes to the current script.
• Save All Scripts — save changes to all scripts with unsaved changes.
• Revert Script — revert the current script to its last saved state.
Writing Scripts
The first time you open the Script Workspace in a new database file, the dialog will be completely blank
except for a Create Script button, as shown in Figure 34-14.
738
Chapter 34 ■ Introduction to Scripting
Figure 34-15. The empty Script Workspace dialog after a script has been created
739
Chapter 34 ■ Introduction to Scripting
Using Auto-Complete
Each new script will start with one blank row showing a text prompt indicating that you can either type a step
or choose from the list in the Steps pane on the right.
If you begin typing a step name into this space, you will see an auto-complete suggestion interface
appear that continuously filters based on what you have typed, as shown in Figure 34-16. You can ignore this
list or use it to quickly enter the desired step.
Figure 34-16. The list of suggested script steps appears as you type, offering to auto-complete the top selection.
To get focus onto the desired step, use any of these methods:
• Scroll and click directly on a desired step.
• Navigate through the list using the Up and Down arrow keys.
• Continue typing enough text until the desired item is at the top of the list.
As the selected step changes, the shaded area at the bottom of the list will update to display a brief
description that will help you identify the selection. Once the desired step is selected, insert it into the script
by either typing Enter or double-clicking on it in the list.
■■Tip For the fastest entry method using auto-complete, skip the cursor and arrow keys. Type enough of the
step’s name until it appears at the top of the list and then type Enter.
Once inserted, the script step is no longer text based and can’t be edited as text. Instead, they become
selectable objects, some with clickable interface elements used for configuration of optional behavior.
740
Chapter 34 ■ Introduction to Scripting
Once a desired step is selected, insert it into the script workflow by any of the following methods:
• Type the Return or Enter key.
• Double-click on it with the cursor.
• Open the step’s contextual menu and select Insert into Script.
741
Chapter 34 ■ Introduction to Scripting
Copy/Paste
One or more steps can be inserted into a script workflow by using the copy and paste functions. The steps
can be copied from the within the same script or from another script in the same or a different database file.
To select multiple steps at once, use any of the following methods:
• To select a single step, click on it.
• To select a sequence of consecutive steps, click on the first step in the desired range
and then click on the last while holding down the Shift key.
• To select a sequence of non-consecutive steps, click on the steps one at a time while
holding the Command (macOS) or Windows (Windows) key.
Copy the steps with the Edit > Copy menu item. Then click anywhere into a script and paste using the
Edit > Paste menu item.
New Record/Request
Go to Next Field
Select All
Beep
Loop
End Loop
There is no configuration possible for these types of steps beyond including them at a particular
position within the workflow.
742
Chapter 34 ■ Introduction to Scripting
The way a step’s settings are modified will vary greatly from one step to another. These can be roughly
divided into two groups:
• Configuring settings directly inline
• Configuring settings with an options dialog
While each of these is described here discreetly, many script steps combine them depending on the
option type.
Figure 34-18. The if function step, showing the formula text editing control in three stages: at rest, with
cursor hover, and with active focus
■■Note Inline formula editing is intended as a convenience for quickly entering a short formula but may be
impractical for longer formulas. Therefore, this input style is always accompanied with an fx icon to the right
of the active area. Clicking the icon will open a full-sized Specify Calculation dialog window into which
complex formulas can be entered.
The text area is a fully featured editor like that found in the Specify Calculation dialog. It includes
auto-complete suggestions and allows for multi-line formula entry and editing, both shown in Figure 34-19.
743
Chapter 34 ■ Introduction to Scripting
Figure 34-19. An example of a multi-line formula entered directly with the auto-complete suggestion
menu visible
After typing compile and save by clicking outside of the formula area or by typing either the Return or
Enter key. If a syntax error is detected, the Specify Calculation dialog will automatically open with an
error notification dialog, forcing you to correct the error or finish the formula before saving.
■■Tip To insert a carriage return in the formula, type Return while holding down the Option key in macOS.
Figure 34-20. The Enter Browse Mode step, shown in stages: at rest, with cursor hover, and after a click
To change the value from its current state to the opposite, click on it or press the space bar. Also the left
and right arrow keys can highlight these buttons.
744
Chapter 34 ■ Introduction to Scripting
■■Tip When this editing method is available in combination with other methods, such as a dialog or popover, the
setting controlled by the toggle button is generally only accessible inline and not from the corresponding dialog.
Figure 34-21. The Go to Record/Request/Page step, shown in three stages: at rest, with cursor hover, and
with active focus
745
Chapter 34 ■ Introduction to Scripting
Figure 34-22. An example of an options dialog opened by clicking on the icon that appears when the cursor
hovers over the statement
Options dialogs will vary greatly and contain a variety of different controls. They may contain one or
more buttons that open additional dialogs. They may include one or more formula fields with adjacent
Specify buttons that open a Specify Formula dialog. Once configured, clicking either the Cancel or Save
button will close the dialog either discarding or saving changes respectively.
When the options are too complex to be placed inline but not numerous enough to justify a full dialog,
a script step may open a small popover dialog when clicking on the gear icon or pressing the space bar, as
shown in Figure 34-23.
Figure 34-23. An example of an options popover dialog opened by clicking on the icon that appears when the
cursor hovers over the statement
Option popovers are almost exactly like dialogs and can contain a variety of different controls. However,
unlike dialogs, any changes made to the settings they contain will be saved immediately.
A popover dialog can be closed by clicking on the script workspace outside of the dialog boundaries or
typing either Enter or Return.
746
Chapter 34 ■ Introduction to Scripting
• Clicking directly on a parameter that defines a field or script reference will instantly
open the Specify Field or Specify Script dialog.
• Double-clicking anywhere on a step will either open the full dialog of options the
same as the gear icon or provide a shortcut to the dialog’s primary setting.
• The Perform Script step has no gear icon and will open the Specify Script dialog
if you click on the parameter or double-click anywhere on the step’s statement.
• Clicking on a field definition parameter of a Go to Field step or double-clicking
anywhere on the step will open the Specify Field dialog while clicking on the gear
icon will open a popover dialog with a handful of options, including a Specify field
button, as shown in Figure 34-24.
Figure 34-24. The Go to Field script step popover contains a handful of options while a direct-click or
double-click provides a shortcut for the Specify Field dialog
• The Insert Text step, which displays several items on a popover, as shown in
Figure 34-25, will open a dialog to specify the text to be inserted into the field when
double-clicking anywhere on the step. In this case, the Specify Field dialog can be
accessed only through the popover dialog.
Figure 34-25. The Insert Text script step popover contains a handful of options while a direct-click or
double-click provides a shortcut for the Specify text dialog
For more examples of the specifics of entering options for various steps, see Chapter 35.
Script Comments
A script comment is a nonfunctioning step that stores and displays developer-entered text in a script. Comments
will appear as a line of text, colored green by default with a pound or hash symbol preceding it, for example:
# This is a comment
747
Chapter 34 ■ Introduction to Scripting
Multi-line comment can be created by typing Return while holding down the Option key in macOS.
Comments are generally used to provide developer documentation by describing the functions of an
entire script or of a group of steps within a script. When combined with empty comments, they separate
section of a script into a visually pleasing delimitation of the steps, making reading, evaluating and editing a
script a much easier prospect, as shown in Figure 34-26.
Figure 34-26. A script with several comments that document the overall function at the start and then
separate and describe groups of steps
■■Tip One creative use for script comments is as an outline mechanism. When planning a new script, create a
sequence of comments that describe each step or group of steps, using the comments as “pseudo-code.” Then,
as you insert and configure actual script steps, revise the comment into a group description or delete them.
Summary
In this chapter, we introduced scripting basics, working in script workspace and various methods of
configuring step options.
748
CHAPTER 35
The possibilities for scripting in FileMaker are numerous. There are over 160 script steps that are used to
create scripts to perform just about any database task you can imagine. There is no way to exhaustively cover
these all in a single chapter or even an entire book. Most steps have a corresponding menu function and
should therefore be intuitively accessible with a relative minimum of experimentation.
In this chapter, we will work through a handful of basic real-world examples to provide a foundation
upon which to base your own exploration of the remaining script steps.
Setting Variables
Variables store information for later access in the database. They can contain any supported data type, can
have multiple repetitions, and be local to a script or global to the database file. Local variables allow a script
to store a value at one position for use later, which is useful when the interface context changes and fields
from a starting context are no longer accessible.
■■Caution Local variables are not inherited up and down the script stack. So, when a script sets a variable
and then runs another script, that sub-script will not have access to the local variable set in the parent script
and vice versa.
Variables do not need to be initialized. If a formula attempts to access a variable that has not yet been
initialized, the result will be a null string. The Set Variable script step can set the value of a local or global
variable. To do this, insert the Set Variable script step into a script, then open the Set Variable Options
dialog, shown in Figure 35-1, by either double-clicking on the step or clicking the gear icon next to it.
750
Chapter 35 ■ Common Scripting Tasks
2.
Value — contains the actual value stored in the variable: either enter a static
value or click the adjacent Specify button to enter a formula in a Specify
Calculation dialog.
3.
Repetition — a number specifying which repetition of the named variable
should receive the specified value. The default will always be 1 for a single
repetition variable.
■■Note When using the script step to set variables, each repetition must be set in its own step.
This example uses the Set Variable step to store name of the current company record and a count
of the number of contacts associated with it for use later in a dialog. These values are then compiled into a
delete warning dialog message that is presented using the Show Custom Dialog step. Finally, the button the
user clicks is placed into a $button.clicked variable that the subsequent script steps can use to determine
the proper course of action.
Go to Layout
The Go to Layout script step, shown in Figure 35-2, is used to change the current layout of the current window.
751
Chapter 35 ■ Common Scripting Tasks
1 2
2.
If the database is used in FileMaker Go, click on the Animation option to reveal a
menu of choices for how the layout switch should be rendered. This setting will
be ignored when running the script on other platforms.
Go to Record/Request/Page
The Go to Record/Request/Page script step, shown in Figure 35-3, is used to change the content of the
current window, depending on the mode as follows:
• In Browse mode, it will navigate to the specified record.
• In Find mode, it will navigate to the specified find request.
• In Preview mode, it will navigate to the specified page.
1 2
753
Chapter 35 ■ Common Scripting Tasks
2.
When selecting Previous or Next, an additional Exit after last option
appears, which can be set to On or Off. If the script step is placed within a Loop
function in the script and this parameter is set to On, the script will automatically
exit the Loop after reaching the last available record in the direction indicated by
the first parameter:
• Previous will exit after reaching the first record in the found set.
• Next will exit after reaching the last record in the found set.
The following example shows a hypothetical universal script that can be used for four different
navigation buttons on every layout in a database. The script reacts to a user clicking on a button indicating
a desire to go the first, last, next, or previous record. The buttons identify themselves and the desired
navigation with a parameter that the script uses to conditionally select the clause of an If statement to take
the appropriate action:
Go to Related Record
The Go to Related Record step performs the following three functions as a single step:
• Navigating to another layout.
• Performing a find for one or more records related to the current record or to every
record in the current found set.
• Optionally creating a new window in which to display the results.
To illustrate the functionality, imagine a user is viewing a Contact record and wants to view the record
for that contact’s parent Company. Instead of manually changing layouts and performing a find, a button can
be added to the layout that performs the Go to Related Record script step or runs a script that includes
that step with other actions. With a click of that button, the window changes layouts and displays the
Company record assigned to the contact they were previously viewing.
In this example, Contact is called the source table and Company is considered the target table, each
being on one side of the relationship between two records from the perspective of the starting layout’s table.
The same relationship used to display a related company name on a contact layout is the conduit through
which the script step will navigate. By traveling “through” the relationship, the match fields used to form the
relationship act like the search criteria for the record(s) that will be displayed in the target table.
Once the step is added to the script or assigned to a button, the Go to Related Record Options dialog,
shown in Figure 35-4, is used to configure the action.
754
Chapter 35 ■ Common Scripting Tasks
3
4
5
6
755
Chapter 35 ■ Common Scripting Tasks
4.
By default, the Specify Layout dialog in Step 3 will display a list any layouts
for the target table from the current database file, even if the other side of the
relationship is a table from an external database file. If the target table is from
an external data source, the Use external table’s layouts check box will
be enabled. When enabled, the Specify Layout dialog will instead show a list of
layouts for the target table from the external database file, and the script step will
display the results in that file.
5.
The Show in new window check box and adjacent Specify button allow the step
to display the results in a new window instead of the starting window. These
settings are identical to the New Window script step described later in this chapter.
6.
The Show only related records option allows control over the context of
records that will be displayed on the target layout. There are three options
available for this setting:
• When the check box is disabled, the related record from the target table will be
displayed in one of two ways depending on whether it is contained in the current
found set on the target layout. Essentially, the step attempts to preserve the
current found set in the target layout if possible. If the target record is present
in that found set, the record will be displayed without changing the found set. If
the target record is not present in that found set, the record will be displayed in a
found set of every record in the database.
• When the checkbox is enabled and the Match current record only radio
button is selected, the target record will be displayed in a new found set of only
those records matching the criteria to establish a relationship to the starting
record. This is the equivalent of a one-to-many search, where the current record
is used to find matching records in the target table.
• When the checkbox is enabled and the Match all records in the current
found set radio button is selected, the target record will be displayed in a
new found set of every record in the target table that has a match to any
record in the found set in which the starting record resides in the starting layout.
This is the equivalent of a many-to-many search, where the current found set of
records is used to find matching records in the target table.
756
Chapter 35 ■ Common Scripting Tasks
Go to Field
There are three script steps that allow navigation to a field on the current layout:
• Go to Next Field
• Go to Previous Field
• Go to Field
The first two of these have no parameter options. They will simply move active focus to the next or
previous field on the current layout based on the field tab order. If the current record is not open and no field
has focus, these steps will open the record and place focus respectively in the first or last field in the tab order.
The Go to Field step, shown in Figure 35-5, moves focus to a specific field.
Click the gear icon to open the panel and configure the following options:
• Select/perform — enable this check box to select all field contents and/or to
automatically open interface elements such as drop-down lists or calendars when
entering the field.
• Go to target field — click the Specify button to open a Specify Field dialog to
select the desired field that should receive focus.
■■Caution The selected field must be present on the current layout and the user must have access to enter
it in the current mode. If no target field is selected or if that field is not present or not accessible, the step will
exit every field and commit the record.
Set Field
The Set Field step, shown in Figure 35-6, will change the value of a specified field for the current record.
The field being set does not need to be in focus or even present on the current layout. The value of any field
local to the layout’s table or in a related table accessible from the current layout’s context can be set using
this step.
757
Chapter 35 ■ Common Scripting Tasks
After inserting the script step into a script or selecting it as a button’s action, click on the gear icon to
open the panel and configure the following options:
• Specify target field — click the Specify button to open a Specify Field dialog
to select the desired field that should receive the calculated result.
• Calculated result — click the Specify button to open a Specify Calculation
dialog to enter a calculation that results in a value that will be placed into the field.
■■Caution If you don’t specify a target field and the record is open, the calculated result will be placed into
the current field with focus.
Click on the gear icon to open the panel and configure the following options:
• Specify target field — click the Specify button to open a Specify Calculation
dialog to enter a formula that results in a text-based reference to the field whose
value should be set. This must include the name of the table occurrence to provide
the necessary context of locating the field.
• Calculated result — click the Specify button to open a Specify Calculation
dialog to enter a calculation that results in a value that will be placed into the field.
For example, to set the Contact Address State field for a Contact record:
Since the field reference is text determined by a formula, it can include conditional variations or be
constructed more dynamically. This example dynamically builds a reference to a standard Record Notes
field for the table of the current layout, which would work in any table containing a field of that name:
Set Field By Name [ Get ( LayoutTableName ) & "::Record Notes" ; "Hello World" ]
Set Selection
The Set Selection step, shown in Figure 35-8, will select a portion of text within a specific field.
Click on the gear icon to open the panel and configure the following options:
• Go to target field — click the Specify button to open a Specify Field dialog
to select which field will receive focus and have text selected. If the check box is left
disabled, the content of the field with current focus will be selected.
• Specify selection — click the Specify button to open a Specify Set Selection
dialog. This dialog has two text areas that can each receive a numeric value or a
formula: Start Position and End Position.
When the step is executed, the selected field will become active and the specified characters of the text
will be selected, as shown in Figure 35-9.
■■Tip To select the entire contents of the current field, use the Select All step.
759
Chapter 35 ■ Common Scripting Tasks
The change is made to the field definition directly, so the specified field does not have to be visible on the
current layout. In many cases, it doesn’t need to be part of the current layout’s table.
Click on the gear icon to open the panel and configure the following options:
• Specify target field — click the Specify button to open a Specify Field dialog
to select which serial number field should be updated.
• Calculated result — click the Specify button to open a Specify Calculation
dialog and enter a formula that returns the next serial value that should be assigned
to the field.
A migration import script might include the following function for each table in which data is imported
or updated:
760
Chapter 35 ■ Common Scripting Tasks
if the serial number is six digits with leading zeros, the following formula can be used to determine the next
value. In this example, the formula standardizes the number of leading zeros on a serial number regardless
of its length by adding six zeros to the left of the value and then extracting six digits from the right, so that any
starting value of one to six digits will still produce a result of six digits:
Get Directory
The Get Directory step, shown in Figure 35-11, presents the user with a Choose Folder dialog prompting
them to choose a folder location for use later in the script. This allows user-specified locations for importing,
exporting, and saving various resources.
Click on the gear icon to open the panel and configure the following options:
• Allow Folder Creation — when enabled, this allows the user to create new folders
from within the Choose Folder dialog.
• Variable — click the adjacent Specify button to open a Set Variable Options
dialog to determine the name of the variable into which the selected folder path
should be placed.
• Dialog title — click the adjacent Specify button to open a Specify Calculation
dialog in which you can enter a formula for the text prompt instructing the user what
to select in the Choose Folder dialog.
• Default location — click the adjacent Specify button to open a Specify
Calculation dialog in which you can enter a formula that determines the folder
location that will be displayed in the Choose Folder dialog by default.
The dialog shown in Figure 35-12 shows how the various settings affect the resulting dialog. Once the
dialog is open, the user can navigate anywhere on their own computer directory and any network servers
that they can access. Once they select a folder and click Select, the path to that folder will be placed into the
variable specified.
■■Caution The exact appearance of the Choose Folder dialog will depend on the operating system and the
user configuration choices made by the user. For example, the current version of macOS (Sierra) doesn’t display
the dialog title prompt, which may confuse users by not making clear why they are selecting a folder.
761
Chapter 35 ■ Common Scripting Tasks
Figure 35-12. A hypothetical Get Directory configuration and the resulting dialog
Import Records
The Import Record step, shown in Figure 35-13, is used to import records into a table with or without
human interaction, depending on the configuration settings.
762
Chapter 35 ■ Common Scripting Tasks
Click on the gear icon to open the panel and configure the following options:
• With dialog — toggle this embedded parameter setting to instruct FileMaker to turn
import dialogs On or Off when the step is performed. If a data source or import order
is not defined in the other parameters, this setting will be ignored and the dialogs will
appear, requesting the missing information.
• Verify SSL Certificates — enable this check box when importing XML data from a
server specified with a HTTP request.
• Specify data source — specify the data source for the import. You can choose
between File, Folder, XML Data, and ODBC Data. The subsequent options dialog will
vary depending on your choice.
• Specify import order — opens an Import Field Mapping dialog in which to
instruct the step about how data in the source should flow into the database.
■■Note To see examples of the Import and Export dialogs encountered when configuring script steps and a
list of supported file types, see Chapter 5.
Export Records
The Export Record step, shown in Figure 35-14, allows a script to automatically export records with or
without human interaction, depending on the configuration settings.
763
Chapter 35 ■ Common Scripting Tasks
After inserting the script step into a script or select it as a button’s action, click on the gear icon to open
the panel and configure the following options:
• With dialog — toggle this setting to instruct FileMaker to turn export dialogs On
or Off when the step is performed. If the export output file and field order are not
defined in the other parameters, this setting will be ignored and the dialogs will
appear requesting the missing information.
• Specify output file — opens a Specify Output File dialog, choosing the file
path into which the data should be saved.
• Specify export order — opens a Specify Field Order for Export dialog to
instruct the step about how data in the source should flow into the database.
Configuring a Dialog
The General tab of the Show Custom Dialog Options dialog, shown in Figure 35-15, is used to configure a
custom dialog.
764
Chapter 35 ■ Common Scripting Tasks
Figure 35-15. The General tab of the Show Custom Dialog Options dialog showing how settings manifest in
the dialog being generated
To configure the Show Custom Dialog Options dialog, follow these steps:
1.
Enter an optional Title for the dialog.
2.
Enter a Message for the body of the dialog.
3.
Enter up to three button names for the dialog. These will appear in the dialog
from right to left with the Default Button being highlighted and responsive to
the user typing the Enter key. If the current record has uncommitted changes at
the time the dialog is presented, each enabled Commit Data check box will cause
the adjacent button to commit the current record when a user clicks it.
Each of the above components can be entered by either:
• Typing directly into the appropriate text area.
• Clicking the adjacent Specify button to open a Specify Calculation dialog and
then entering a formula that results in text.
■■Caution Custom dialogs do not automatically resize based on the amount of text entered, so a lengthy
Message may be cut off. The user can resize the dialog to read additional information; however, since it is not
visually apparent that more text is available or that the dialog can be resized, it is a good idea to try to keep
dialog messages concise when using the Show Custom Dialog step.
765
Chapter 35 ■ Common Scripting Tasks
Figure 35-16. The Input Fields tab of the Show Custom Dialog Options dialog
The dialog repeats the controls for up to three fields. Each section, like the one shown in Figure 35-17,
can be activated and configured to include one field.
1
2
3
Figure 35-17. One set of field controls showing how field settings appear in a dialog
766
Chapter 35 ■ Common Scripting Tasks
■■Tip When a dialog requires more than three button choices or needs to contain more than text, use the
New Window script step to generate a fully custom dialog as a stand-alone window or attached to the current
window using the new Card option.
In the above example, if there are three buttons — OK, Cancel, and Help — and the user clicks Cancel,
the $function variable will be set to a value of 2.
Convert the button index back into a name with the Set Variable function using a Let and Case
statement, as shown in the following formula:
Let (
number = Get ( LastMessageChoice )
;
Case (
number = 1 ; "OK" ;
number = 2 ; "Cancel" ;
"Help" )
)
767
Chapter 35 ■ Common Scripting Tasks
If [ <criteria> ]
<conditional steps>
End If
For example, this statement will display the specified dialog if the current user account is assigned a
privilege set that allows full access to the database:
In the above example, if the user does not have the access specified, no action is taken and the script
continues performing other steps not contained within the statement (not shown). However, to add an
alternative set of steps that are executed if the initial criteria returns a false value, use an Else step, as shown
in this pattern formula:
If [ <criteria> ]
<conditional steps 1>
Else
<conditional steps 2>
End If
In the following example, a dialog will be displayed with a different message depending on the user’s
privilege set. If the user has full access, they receive a dialog identifying and greeting them as a developer. If the
user has any other access level, they receive the greeting in the second dialog step.
768
Chapter 35 ■ Common Scripting Tasks
If [ <criteria 1> ]
<conditional steps 1>
Else If [ <criteria 2> ]
<conditional steps 2>
Else If [ <criteria 3> ]
<conditional steps 3>
Else
<conditional steps 4>
End If
The statement begins with an If step that contains the first combination of criteria and conditional
steps. Each subsequent set of criteria steps is initiated by an Else If step, until finally the statement is
terminated with an End If after an optional Else that allows for a final set of steps conditionally run if all the
above are false.
The script will work from the top down, evaluating each criteria until one results in a true value. Once
it encounters a true result, it will run the enclosed conditional steps and then skip all other criteria and
conditions.
In this example, a different hypothetical email script is performed depending on the Status field of an
Invoice record:
If [ Invoice::Status = "Paid" ]
Perform Script ["Email Invoice Paid" ]
Else If [ Invoice::Status = "Past Due" ]
Perform Script ["Email Invoice Past Due" ]
Else If [ Invoice::Status = "Due" ]
Perform Script ["Email Invoice Due" ]
End If
Performing Searches
There are several different steps that perform searches. These can be used separately or combined with steps
that perform navigation, sorts, compilations, and batch processes.
The following two steps are used to perform searches:
• Perform Quick Find — This step is configured with a formula whose result will be
used to search within any field on the current layout that has Quick Find enabled
(Chapter 4, “Searching with Quick Find”).
• Perform Find — This step is configured with a Specify Find Request dialog in
which complex find criteria can be entered (Chapter 4, “Managing Saved Finds”).
The Enter Find Mode step, shown in Figure 35-18, is used to initiate a find request, optionally providing
some starting criteria.
The Enter Find Mode step will switch the current window into Find mode and has the following two
configuration options:
• Pause — When this setting is On, the script will enter Find mode and pause to allow
a user to enter find criteria or perform other actions. The user will have to press the
Enter key or click the Continue or Cancel button in the second level of the status
toolbar to continue the script.
• Specify find requests — This setting opens a Specify Find Request dialog in
which complex find criteria can be entered that will be automatically set up after
entering Find mode.
Since the step does not perform a find itself, it allows for situations where the user or other script
steps add additional criteria. Subsequent Set Field steps can be added to set up additional, dynamically
calculated criteria beyond the entries made by the user or the Specify find requests setting.
A Perform Find step must be added at some point to perform the find.
A find script can take many forms. It may perform a find based on static unchanging criteria, build the
find based on variables, solicit user criteria, or some combination of these. This example script uses one
hard-coded criterion and one user entered. It sets up an invoice search for invoices with a Status of “Paid”
and then presents a dialog allowing the user to enter a date range into an Invoice Date field. Once the user
enters a date range and presses the Enter key, the resulting search will find all paid invoices that have a date
that falls within the range entered by the user. The script includes a conditional dialog that appears if no
records are found.
770
Chapter 35 ■ Common Scripting Tasks
771
Chapter 35 ■ Common Scripting Tasks
Go to Record/Request/Page [ First ]
Loop
<insert task steps>
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
■■Caution If the Exit after last parameter is turned Off and no other steps exit the loop, the script will be
caught in an endless loop. The user can only escape an endless loop by typing Esc or a Period while holding the
Command key (macOS) key if the Allow User Abort setting is On; otherwise, the application must be force quit.
Go to Record/Request/Page [ First ]
Loop
# Add body row
Set Variable [ $Body ; $Body &
Invoice::Record ID & " " &
Invoice::Invoice Date & " " &
772
Chapter 35 ■ Common Scripting Tasks
For each record in the found set, the Set Variable step adds a new paragraph to the $Body variable
containing the values stored in five fields. After this script finishes, the $Body variable will contain a text list
of open invoices that might look something like this:
Open
1003 06/1/2017 Fantastic Client $4,500
1003 06/15/2017 Fantastic Client $958
Over 30 Days
1002 05/19/2017 Creative Company $3,000
Over 60 Days
1001 04/15/2017 Fantastic Client $1,000
1001 04/15/2017 Fantastic Client $1,000
To achieve this result, the following modifications are needed to detect and insert a heading every time a
status change is detected and then store that status to avoid heading duplication:
• A variable named $Last.Status will be initialized at the start with an empty string
and then used to store the last status heading that has been encountered and added
into the results.
• At the beginning of the Loop statement, the Invoice Status field value will be
placed into a variable named $Status to shorten it for easier use repeatedly in a new
conditional statement.
• An If statement will be added to handle the insertion of the status heading into the
result and tracking this fact. A new status is detected when $Status is not equal to
$Last.Status.
773
Chapter 35 ■ Common Scripting Tasks
774
Chapter 35 ■ Common Scripting Tasks
By dynamically counting the number of state values in the list and exiting when the next $Current value
exceeds that count, the script will work for any number of states listed in the variable. It continues to repeat
on to the next value until it reaches the end of the list and the Exit Loop If condition is true.
Figure 35-19. A dialog prompting the user to enter an invoice status that will be used to perform a search
If the script continues executing beyond this point, we know that the user has clicked the Search
button. In the next section, a Loop statement is used to confirm that a value was typed into the field. This is
accomplished by performing the following functions:
• The first step within the Loop statement uses an Exit Loop If step to immediately
exit the statement if the user followed the instructions and did, in fact, enter a value.
If they did not enter a value, the expression returns a false value and the script stays
within the statement.
• The Beep step causes the computer to sound an audio alert.
• A dialog identical to the original but with a slightly enhanced message is opened,
explicitly stating that a status is required.
775
Chapter 35 ■ Common Scripting Tasks
• When the user clicks a button on the dialog, one of three actions occur:
• If they click the Cancel button, the script will return to Browse mode and exit.
• If they click the Search button without enter a value, the Loop statement repeats,
presenting another dialog.
• If they click the Search button with a value entered, the Loop statement starts to
repeat but exits with the Exit Loop If step immediately at the top.
The preceding steps are expressed in the following script steps:
Loop
Exit Loop If [ Invoice::Invoice Status ≠ "" ]
Beep
Show Custom Dialog [ "Search" ; "A status is required:" ; Invoice::Invoice Status ]
If [ Get ( LastMessageChoice ) = 2 ]
Enter Browse Mode
Exit Script
End if
End Loop
Once the loop is exited, the script can continue, performing the find and taking whatever additional
steps are necessary to complete its task.
Exit Loop If [
Invoice::Invoice Status ≠ "Paid" and
Invoice::Invoice Status ≠ "Open" and
Invoice::Invoice Status ≠ "Past Due" and
Invoice::Invoice Status ≠ "Over 30 Days" and
Invoice::Invoice Status ≠ "Over 60 Days" and
Invoice::Invoice Status ≠ "Over 90 Days" and
Invoice::Invoice Status ≠ "Over 120 Days"
]
To avoid hard-coded values, the formula could instead get a list of acceptable values from the same
value list associated with the status field being searched. This example assumes the existence of a value list
named Invoice Status that contains all the available options for the field and uses that to confirm that the
value entered in the dialog is appropriate:
Let (
Values = ValueListItems ( Get ( FileName ) ; "Invoice Status" ) ;
Not IsEmpty ( FilterValues ( Values ; Invoice::Invoice Status ) )
)
776
Chapter 35 ■ Common Scripting Tasks
■■Tip An even more sophisticated option is to generate a fully custom dialog using the New Window step
described later in this chapter. This would allow the inclusion of a pop-up menu of choices to relieve users of
the need to remember and type valid values and instead simply select a value from the list.
Go to Related Record [
From table: "Company | Contact" ;
Using layout: "Contact Form" (Contact)
]
Sort Records [ Restore ; With dialog: Off ]
<Insert Other Steps>
777
Chapter 35 ■ Common Scripting Tasks
Remember that a script attached to a button in a portal row will operate based the context of the row the
user clicks on. Therefore, be sure to perform context-sensitive steps within the script before performing steps
like committing a record or changing layouts.
When running a script by clicking a button on a Contact portal row in a portal on a Company layout, any
references to any field in the related Contact table will be pulled from the row clicked until an action is taken
that commits the current record. Once the record is committed, any references to related fields will be pulled
from the first row. Similarly, once the script has performed the Go to Related Record step, the context will
change to the destination table occurrence so the fields selected in the Sort Records step must be from that
context and not the original context.
When this script runs, from the user’s perspective, nothing will have changed except for the appearance
of a new row in the portal.
778
Chapter 35 ■ Common Scripting Tasks
Managing Windows
There are numerous script steps that allow for the manipulation and management of windows, including:
• Adjust Window — adjust the visibility or size of a window based on the following
options:
• Resize to Fit — adjust the dimensions of the window to the minimum size
possible while continuing to display the entire content area.
• Maximize — resize the window to the full size of the computer screen on which
is it currently displayed.
• Minimize — shrink the window down to an icon stored in the Dock (macOS) or
taskbar (Windows).
• Restore — returns the window to the size and position as it was at the
beginning of the script.
• Hide — hide the window from view, placing it into the Window > Show Window
menu from where it can be reopened.
• Arrange all Windows — arranges all the open windows by the selected method:
• Tile Horizontally
• Tile Vertically
• Cascade
• Bring All To Front
• Select Window — bring a specified window to the front of every other window.
• Move / Resize Window — adjust the Height, Width, Distance from Top, and
Distance from Left for a specified window.
• Close Window — close a specified window.
• Freeze Window — lock the active window from refreshing during the remainder of a
script. This helps to speed up a scripted process and hides layout and record changes
from being a distraction to the user.
• Refresh Window — update the active window’s record content.
• Scroll Window — scrolls the window view by the selected method:
• Home
• End
• Page Up
• Page Down
• To Selection
• Set Window Title — change the title of a specified window.
779
Chapter 35 ■ Common Scripting Tasks
2
3
■■Note A window is considered modal when it forces the user to interact with and/or dismiss it before they
can resume work in the application or window.
780
Chapter 35 ■ Common Scripting Tasks
2.
Optionally, enter a Window Name into the text area or click the fx button to enter
a formula to dynamically calculate a name. If no name is specified, the new
window will be named the same as the current window with a numeric suffix.
3.
Optionally, select a Layout that should be displayed in the new window.
4.
Optionally, enter a Height and Width to control the Size of the new window by
typing directly into the text areas or clicking the fx button to enter a formula to
dynamically calculate them.
5.
Optionally, enter a From Top and From Left value to control the Position of
the new window by typing directly into the text areas or clicking the fx button to
enter a formula to dynamically calculate them.
■■Tip Developers often create “staging” windows that have a large negative value for the From Left and
From Top properties to keep them hidden offscreen. These are ideal when a script performs several preparatory
steps before presenting a window to the user or when performing a complex sequence of automated steps that
would be a distraction to a user if in full view.
6.
Select from the list of available Window Options to control the following
properties of the new window:
• Close — enables a standard close window control.
• Minimize — enables a standard minimize window control.
• Maximize — enables a standard maximize window control.
• Resize — allows the user to manually resize the window after it is created.
• Menubars — controls if the menubar is visible at the top of the window
(Windows only).
• Toolbars — controls if the status toolbar is visible.
• Dim Parent Window — Dims the parent window (Card only).
■■Caution If you present a modal window without access to the close function and without providing a
button that closes the window, the user will be stuck and must force quit the application to continue.
781
Chapter 35 ■ Common Scripting Tasks
■■Tip Notice that we have named these fields generically and included two fields that the script will use to
specify the name of the button. This will allow the table and fields to be expanded in the future and be used to
generate any number of additional dialog types.
782
Chapter 35 ■ Common Scripting Tasks
Since this dialog will pull field values as the button names and since a field object can be converted into
a button, either of the following two options can create the buttons:
• Create buttons and use a merge field for the name property: <<fieldname>>.
• Create the fields on the layout along with a temporary button. Then use the Format
Painter tool to copy and paste the style settings from the actual button to the text
fields. The resulting fields will appear to be buttons, as shown.
Enter Browse mode and create a new empty record in the Dialog table.
783
Chapter 35 ■ Common Scripting Tasks
• Using the Freeze Window command to lock the interface until it needs to be
refreshed to avoid unnecessary distractions.
Then, an If statement encloses lines 8-9 so that they only run if the script parameter contains “Cancel”
indicating that the user is already interacting with a dialog generated from a previous execution of the script
and has clicked the Cancel button:
• Using the Close Window step, the dialog is closed, returning the user to the window
they started in.
• The Halt Script step is used to stop the script, returning the interface to normal use.
If the script parameter did not indicate a cancellation process, the script assumes we are generating a
new dialog and continues to lines 13-16. Here it initalizes variables that will be used to populate fields in the
dialog. The $Body variable is the only one of these that contains dynamic text and must be initialized before
the window changes layouts since it includes the name of the table in which the user is attempting to delete
a record. Using the Get ( LayoutTableName ) to generate the dialog body message assumes that the layout
table is named as a singular descriptive version of the type of records in that table. For example, a table named
Contact or Company will make sense using the formula shown, but a table named in the plural (Invoices) or
named abbreviated (Invo Recs) will not make sense when placed into sentence form.
The window is created in line 19 by the New Window step configured as shown in Figure 35-23.
784
Chapter 35 ■ Common Scripting Tasks
785
Chapter 35 ■ Common Scripting Tasks
Figure 35-24. The configuration of the Dialog Button 1 field on the Dialog layout
Select the Dialog Button 2 field and configure it to run the Delete Record {function} script by
following these steps:
• Select the Format > Button Setup menu item and set the Action to perform a
Perform Script.
• In the Specify Script dialog, select the Delete Record {Function} script.
• Enter “Cancel” into the Optional script parameter text area.
• Click OK to close the Specify Script dialog.
• Select Halt Current Script in the Options area of the Button Setup dialog.
• Also, check the Change cursor to hand over button option. See Figure 35-25.
786
Chapter 35 ■ Common Scripting Tasks
Figure 35-25. The configuration of the Dialog Button 2 field on the Dialog layout
In the Data > Behavior section of the Inspector, confirm that all the fields on the layout except Dialog
Confirmation Entry have no Field Entry options selected.
Finally, select the Layouts > Set Tab Order and click Clear All in the Set Tab Order dialog. Then
click the arrow pointing to the Dialog Confirmation Entry field and then on the arrow pointing to the right
side of the Dialog Button 1 field/button, as shown in Figure 35-26. This will allow the user to type into the
confirmation field and then tab to jump to the Delete button. Click OK to save the new tab order.
Figure 35-26. The tab order to allow tabbing between the confirmation text field and the first dialog
field/button
787
Chapter 35 ■ Common Scripting Tasks
Figure 35-27. The delete dialog when the script is run from a layout for the Contact table
Type the word “Delete” into the confirmation box and hit the Tab key. That should make the Delete
button visible, as shown in Figure 35-28.
Figure 35-28. The delete dialog after the user types into the confirmation field
■■Tip This dialog and script can be evolved to include various enhancement. For example, the message
could include a value from a standard Record Name field and could be expanded to handle a Delete All
Records request.
788
Chapter 35 ■ Common Scripting Tasks
Figure 35-29. An example of a card superimposing a graphic layout on top of the Sandbox Form layout
Cards are similar in appearance and behavior to modal windows found in other environments. For
example, a macOS dialog can open as a “sheet,” attached to the top of a window. Also, various types of
objects are often displayed atop the content of a web page, including advertisements and images, which are
sometimes loosely referred to as a “Lightbox” effect.
Cards are great for presenting navigation menus custom toolbars, dialogs, and more. Since the card
layout has its own context that can be based on a table occurrence other than that of the parent window’s
layout, a card can provide universal services regardless of the parent window’s context.
■■Tip When configuring a Card in the New Window Options dialog, leave the Size and Position values
empty to have the layout centered in the parent window displaying its content at full size.
789
Chapter 35 ■ Common Scripting Tasks
Figure 35-30. The dialog presented as a Card, attached to the top of the window
■■Caution When the Close Window option is disabled, the card will not include a Close button in the
upper-left corner. You must include at least one button on the layout that allows the user to close the card or it
may become necessary to force quit the application to release the window, especially if the script that opened
the window is paused and has Allow User Abort turned Off.
Managing Errors
When an error occurs, a dialog may appear informing the user of the problem and temporarily pause the
running script. The message in this dialog may or may not make sense to a user depending on the error that
occurs or their knowledge of the script functions and of FileMaker development.
A common scripting error that presents a dialog is an attempt to use the Set Field step to set a value
for a field from the wrong context. For example, if browsing a Company record, setting a field in the Contact
table directly (not through a relationship) will result in the error message stating, “This operation could not
be completed because the target is not part of the related table.” Since this is a programming error, a user
would have absolutely no idea what this means or what to do to reach a resolution.
To suppress error displays, use the Set Error Capture step with a parameter of On. This will cause
the script to ignore any errors it encounters and continue processing. The Get ( LastError ) function
can be used at various points in the script to determine if an error has occurred. The function will return a
numeric value indicating either no error (0) or the number representing the error. An If statement can take
conditional action in the event an error is detected.
790
Chapter 35 ■ Common Scripting Tasks
As an illustration of this technique, the example below shows a script attempting to set a the
Contact::Name Last field and displaying a dialog. If this script is run from a different table, say a Project
table, the Set Field step will generate a 103 error and display the dialog specified.
Generally, it isn’t necessary to put an error check and dialog on a granular level as shown in the
preceding example, which is intended to illustrate the pattern of how errors can be captured, detected, and
reported.
For a complete list of errors, search for “FileMaker Pro error code reference guide” on FileMaker.com.
Summary
In this chapter, we explored many examples of scripting tasks that can be used to automate activity within a
database.
791
CHAPTER 36
Debugging Scripts
Troubleshooting an issue occurring within a simple script doesn’t pose much of a challenge. As a database
grows in complexity, several factors can adversely impact how easily a developer identifies and locates the
cause of a scripting problem. A script can call a sub-script, which can call another in a branching hierarchy.
Scripts are triggered from numerous interface elements such as buttons, layouts, menus, records, and more.
Scripts can jump from one layout context to another, which can be difficult to keep track of during complex
processes that are woven into a mesh of interconnected scripts. To ease the burden of figuring out what is
going wrong and where, modern development environments have a feature called a script debugger.
A script debugger is an interactive tool used by developers to troubleshoot complex scripted processes,
often those involving functions that range across multiple scripts. FileMaker Pro Advanced has a built-in
script debugger that makes it easy to monitor variables, step through scripts and sub-scripts, set and clear
custom breakpoints, pause on errors, and temporarily disable all script triggers to help locate and correct
scripting problems.
In this chapter, we will introduce basic debugging, covering the following topics:
• How script debugging works
• Exploring the debugging interface
• Using the debugger
• Using custom breakpoints
794
Chapter 36 ■ Debugging Scripts
Figure 36-1. The Script Debugger menu items and Debugging Controls submenu
795
Chapter 36 ■ Debugging Scripts
The following controls are available at the top of the Tools menu:
• Script Debugger — This menu item will toggle the visibility of the Script Debugger
window, with a check mark indicating that it is currently open.
• Debugging Controls — This submenu provides key command access to various
debugging functions (described later in this chapter) and displays the status of the
Disable Script Triggers and Pause on error functions.
• Data Viewer — This menu item will toggle the visibility of the Data Viewer window,
with a check mark indicating that it is currently open.
The main portion of the debugger window contains the following interface elements:
1.
Script Name — This area displays the name of the current script being displayed.
2.
Script Step — This area displays the script steps that make up the current
script. If the debugger is paused on a highlighted step, that indicates it has
encountered a natural breakpoint, custom breakpoint, or error and is waiting for
you to choose to stop, continue, or take some other action.
796
Chapter 36 ■ Debugging Scripts
3.
Pause on error — When this check box is enabled the Script Debugger will
pause any time an error occurs, opening the dialog if necessary.
4.
Call Stack — This area contains the “stack” of script calls based on the script
paused in the view. If viewing a sub-script that was called by other scripts, the
disclosure triangle can be clicked to expand the hierarchy above the current
script, tracing back the path to the first script in the stack.
3 5 7 9
1
2 4 6 8
The toolbar contains the following buttons, each connected to a debugging function that is also
available under the Tools > Debugging Controls submenu:
1.
Edit Script — Opens the current script in the Script Workspace window.
2.
Continue — Continues running the script currently paused in the window.
3.
Halt Script — Stops the script and any other scripts in the call stack.
4.
Step Over — Continues running the script without debugging sub-scripts.
5.
Step Into — Continues running the script with debugging sub-scripts.
6.
Step Out — Continues the current sub-script without debugging until control is
returned to the parent script.
7.
Set Next Step — Jump ahead to the script step that is selected in the window,
skipping the interim steps.
8.
Disable Script Triggers — This button will toggle the setting to disable script
triggers throughout the database file.
9.
Open Data Viewer — This button will open the Data Viewer dialog.
797
Chapter 36 ■ Debugging Scripts
Figure 36-4. The Data Viewer dialog is a diagnostic tool that is used to monitor the value of global and local
variables when a script is paused
798
Chapter 36 ■ Debugging Scripts
Once in place, a script run through the debugger will pause at the beginning and then at each of the two
breakpoints.
Breakpoints can be removed by any of the following methods:
• Within a script by clicking on each blue arrow.
• When a script is paused in the debugger, all breakpoints can be removed by selecting
the Tools > Debugger Controls > Remove Breakpoints menu item.
Summary
In this chapter, we explored the benefits and features of the script debugger, which is a valuable tool to assist
in troubleshooting databases with complex scripting.
799
CHAPTER 37
A script connected to a button or one made visible in the Scripts menu will run in response to a user’s click.
While this gives users easy access to a time-saving and error-avoiding sequence of predefined functions, it
has one glaring limitation. The click-to-run approach to scripting requires the user to consciously intend
to perform the script function, knowing when and how to invoke it. So, while the script will automatically
perform the steps defined within, it must be manually triggered. As a developer, you may not want to always
rely on a user to remember to take the right action at the appropriate time. Script triggers solve this problem.
A script trigger is a mechanism that connects a specific interface event to a script so that any time a
user or other script performs the event, the script runs automatically. This feature is like most application
development environments, triggering a function in reaction to an interface event. FileMaker has over two-
dozen triggers for a variety of file, layout, and object events. For example, a script can be configured to run
after the database file opens or before the database file closes. Similarly, a script can run when a layout is
entered or exited; when a field is entered, edited or exited; when a window changing modes; and more.
Every trigger runs in response to an event. However, events trigger a script either before or after the
user’s intended action is completed. For example, when modifying a field or navigating to a layout, the script
is triggered after that event is completed. However, some scripts are triggered before the event is completed.
In those cases, if the script returns a false value of 0, the script triggering action is not completed.
Scripts executed by a trigger are the same as any other script in FileMaker. In fact, events can trigger
scripts that are connected to a button or available in the Scripts menu. Different events or the same
event from different objects can each have their own script, or they can share a script depending on each
developer’s preference or the practicality of doing so within a specific context.
In this chapter, we will introduce script triggers, covering the following topics:
• Script trigger reference
• Working with script triggers
Figure 37-1. The Script Triggers tab for the File Options dialog
802
Chapter 37 ■ Using Script Triggers
OnFirstWindowOpen
The OnFirstWindowOpen event occurs when the first window is created after a database is explicitly opened
by a user or Open File script step in another file. It provides an opportunity to perform any configuration or
setup routines for the file itself at startup. For example, this event might trigger a script that initializes global
variables, automatically opens other windows, or performs default finds and sorts, etc.
■■Caution The OnFirstWindowOpen event does not occur if the file opens as a hidden window due to being
automatically opened by a relationship to it from another database file.
The event will trigger a script after the event has been processed and the window has been opened.
OnLastWindowClose
The OnLastWindowClose event occurs when the last layout window for the file is closed by a user or a Close
Window script step. It provides an opportunity for a script to perform any last-minute validation functions or
maintenance routines.
■■Note This event is based on the last non-developer window being closed and will not consider other
windows such as the Script Workspace.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the Close process will be halted and the window will remain open.
OnWindowOpen
The OnWindowOpen event occurs after any new window is created in response to:
• A user selects the Window > New Window menu item.
• A script runs that uses the New Window step.
• A window for a hidden file is brought into focus by a user or script step for the first time.
803
Chapter 37 ■ Using Script Triggers
This event provides an opportunity to perform any configuration or setup routines for the window. For
example, this event might trigger a script that performs a default find and sort.
The event will trigger a script after the event has been processed.
OnWindowClose
The OnWindowClose event occurs before any window is closed.
This event provides an opportunity for a script to perform any last-minute validation functions or
maintenance routines to the record(s) viewed within the window.
The event will trigger a script in non-Layout modes before the event has been processed. If the script
returns a false value of 0, the process will be halted and the window will remain open.
OnFileAVPlayerChange
The OnFileAVPlayerChange event occurs whenever a user or script changes the playback state of a media
file playing in a field or URL. For example, the event will trigger the script when a user pauses, plays, or stops
the media or when the media stops upon reaching the end.
The event will trigger a script in Browse and Find modes after the event has been processed.
Layout Triggers
A layout trigger will run a script in response to an event while a user is accessing records on a particular
layout. These triggers are available in the Script Triggers tab of the Layout Setup dialog, shown in
Figure 37-2, which can be accessed by selecting the Layout Setup from the layout’s contextual menu or by
clicking the pencil icon to the right of the Layout menu in the lower row of the window toolbar.
804
Chapter 37 ■ Using Script Triggers
Figure 37-2. The Script Triggers tab for the Layout Setup dialog
The dialog controls are the same as those on the File Options dialog with one addition:
• Enable in — These check boxes allow the selected script trigger to be enabled or
disabled for both Browse or Find window modes.
The following layout triggers are available:
• OnRecordLoad
• OnRecordCommit
• OnRecordRevert
• OnLayoutKeystroke
• OnLayoutEnter
• OnLayoutExit
• OnLayoutSizeChange
• OnModeEnter
• OnModeExit
805
Chapter 37 ■ Using Script Triggers
• OnViewChange
• OnGestureTap
• OnExternalCommandReceived
OnRecordLoad
The OnRecordLoad event will occur after a record becomes current, providing an opportunity for a script to
perform actions just prior to a user or script viewing or modifying a record.
The event will trigger a script after a user or script performs any of the following record-loading events:
• Navigating to a new record within a found set
• Navigating to a different layout
• Creating a new record
• Deleting a record in a found set of more than one record
• Creating a new window
• Displaying the results of a Find operation
This event will occur anytime a window displays a record that wasn’t currently displayed in the moment
before on a layout that has a script assigned to this trigger.
OnRecordCommit
The OnRecordCommit event will occur when an attempt is made to commit a modified record by a user or a
script performing any of the following actions:
• Navigating to a different record
• Typing the Enter key
• Clicking anywhere on the layout outside of the fields of the active record
• Changing records; navigating, deleting, creating, duplicating, etc.
• Performing a script containing the Commit Records/Requests step
• Opening the Manage Database dialog window
• Closing the file
This event allows a script to perform validation steps or other actions prior to saving changes made to
the record.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the Commit process will be halted and the uncommitted changes will remain in place on the record, which
will still be in focus.
OnRecordRevert
The OnRecordRevert event will occur when an attempt is made to revert a modified record to its previously
committed state by a user selecting the Records > Revert Record menu or a script is run with the Revert
Record/Request step.
806
Chapter 37 ■ Using Script Triggers
This event allows a script to provide a custom dialog message warning the user to perform any
necessary actions prior to removing recent changes and restoring the record to its last saved state.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the Revert process will be halted, and the uncommitted changes will remain in place on the record, which
will still be in focus.
OnLayoutKeystroke
The OnLayoutKeystroke event will occur when any character is typed on the keyboard except those handled
by the Operating System or FileMaker. For example, the event does occur when typing navigational keys
such as Tab and arrows but is not sent when typing a command by holding down the macOS Command key or
the Windows Alt and Control keys, or function keys like volume buttons.
The script triggered by this event can use various functions to determine the keystroke that triggered it
and what, if any, field has focus and is being typed into. Some useful functions here include:
• Get ( TriggerModifierKeys )
• Code
• Char
• Get ( ActiveFieldName )
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the keystroke will not be processed.
OnLayoutEnter
The OnLayoutEnter event will occur after a layout has loaded. It will trigger a script after the event has
been processed.
OnLayoutExit
The OnLayoutExit event will occur when a user or script attempts to navigate away from the current layout
or to close a window. It will trigger a script before the event has been processed. If the script returns a false
value of 0, the layout change will be halted, and the window will continue to display the previously displayed
layout.
OnLayoutSizeChange
The OnLayoutSizeChange event will occur when the window has changed size due to a user or script
performing any of the following actions:
• Manually resizing the window by dragging
• Running a script that contains a Resize Window step
• Hiding or showing the window toolbar or formatting bar
807
Chapter 37 ■ Using Script Triggers
• Opening a window
• Rotating the iOS device (FileMaker go only)
The event will trigger a script after the event has been processed.
OnModeEnter
The OnModeEnter event will occur after the window mode is changed by a user or a script step. It will trigger a
script after the event has been processed.
OnModeExit
The OnModeExit event will occur when a user or script attempts to change the window mode. It will trigger
a script before the event has been processed. If the script returns a false value of 0, the mode change will be
halted, and the window will remain in whatever mode it was previously displaying.
OnViewChange
The OnViewChange event will occur when a user or script changes the window view between Form, List,
or Table. It will trigger a script after the event has been processed.
OnGestureTap
The OnGestureTap event will occur when a tap gesture is received on a layout under the following
conditions:
• FileMaker go and windows only (except Windows 7)
• Browse and find modes only
• Tap is not made in active web viewers or active edit boxes
• Single tap is one, two, or three fingers (iOS)
• Double tap with one finger (iOS), which will trigger the event twice
• Tap is with two fingers (Windows)
The triggered script can use the Get ( TriggerGestureInfo ) function to determine details about the
gesture event.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the gesture will not be processed.
OnExternalCommandReceived
The OnExternalCommandReceived event will occur when a user presses a button to control playback functions
(play, pause, stop, next, previous, etc.) on an iOS device lock screen or on an external device. The triggered
script can use the Get ( TriggerGestureInfo ) function to gain information about the external event.
808
Chapter 37 ■ Using Script Triggers
The event will trigger a script before the event has been processed.
Figure 37-3. The Set Script Triggers dialog for a selected layout object
809
Chapter 37 ■ Using Script Triggers
• OnObjectExit
• OnPanelSwitch
• OnObjectAVPlayerChange
OnObjectEnter
The OnObjectEnter event will occur when a layout object becomes entered and receives active focus. This
can occur when a user clicks on the object, tabs into the object, or when a script is run that contains a step
causing an object to be entered: for example, the Go to Object or Go to Next Field steps.
The event will trigger a script after the event has been processed.
OnObjectKeystroke
The OnObjectKeystroke event will occur when any character is typed on the keyboard into an object with
focus except those handled by the operating system or FileMaker.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the keystroke will not be registered and the character will not appear in the object.
OnObjectModify
The OnObjectModify event will occur when the value of an object has changed because of any edit
events including:
• Typing keystrokes into the object
• Selecting a new value in a value list formatted field (check box, radio button, etc.)
• Using Cut, Paste, or Clear functions
• Changing the value of the object with a script step such as Insert Text
• The selection of a new tab on a panel control
The event only occurs in response to interface-related actions. It does not occur when a window
updates values that are populated from an external data source, when a field is updated by an auto-enter
formula, or when the Set Field script step is used to update the value of a field.
The event will trigger a script after the event has been processed.
OnObjectValidate
The OnObjectValidate event will occur when a field value has changed and is about to be validated prior
to being saved. This occurs when a user tabs to a new field or commits a record after making changes to the
field with active focus.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
the validation and exit events will be halted and the current object will retain focus.
810
Chapter 37 ■ Using Script Triggers
OnObjectSave
The OnObjectSave event will occur after a modified field is in the process of being exited when focus is
moving to a new field or a record is being committed.
The event will trigger a script after the event has been processed. If the script returns a false value of 0,
the exit object event will be halted and the current object will retain focus; however, the changes will have
already been saved.
OnObjectExit
The OnObjectExit event will occur when an object is about to lose active focus:
• Move from one object with focus to another
• Moving to another portal row
• Moving to another repetition in a repeating field
• Any action that causes the record to be committed
• Opening a dialog that causes a field to be exited
The event will trigger a script before the exit event has been processed. If the script returns a false value
of 0, the event will be halted and focus will remain active on the current object.
OnPanelSwitch
The OnPanelSwitch event will occur when the current tab of a panel control is about to change due to a user
selecting a different tab or a script step selecting an object on a different tab.
Use the Get ( TriggerCurrentPanel ) and Get ( TriggerTargetPanel ) functions to determine
which individual panel of the control is being exited from and which has been selected to receive active focus.
The event will trigger a script before the event has been processed. If the script returns a false value of 0,
it will cause the panel change to be halted.
OnObjectAVPlayerChange
The OnObjectAVPlayerChange event will occur when the media in a layout object changes state. For
example, the event will trigger a script when a user pauses, plays, or stops a video in a field or when the video
stops upon reaching the end.
The event will trigger a script after the event has been processed.
811
Chapter 37 ■ Using Script Triggers
Figure 37-4. The object badge visible on a field with one or more script triggers assigned
■■Note Object Badges are helpful in identifying various features used by a layout object. They are discussed
further in Chapter 15.
812
Chapter 37 ■ Using Script Triggers
• OnRecordLoad
• OnLayoutSizeChange
When changing layouts, the following sequence of events will be triggered in this order:
• OnLayoutExit
• OnLayoutEnter
• OnRecordLoad
■■Caution If the layout change is initiated from a window that has unsaved changes, the sequence listed
here will be preceded by the entire record commit sequence listed previously.
813
Chapter 37 ■ Using Script Triggers
Summary
In this chapter, we continued our discussion of scripting, specifically triggering scripts in reaction to
interface events.
814
CHAPTER 38
A plug-in is a software package developed with the C or C++ programming language that extends the
capabilities of FileMaker Pro by adding new functions accessible through the Specify Calculation dialog
and new script steps.
This chapter covers basic plug-in concepts including:
• Purchasing plug-ins
• Installing plug-ins
• Accessing plug-ins
Purchasing Plug-Ins
Many companies sell plug-ins for FileMaker Pro. A few prominent examples are included here for your
convenience.
360 Works
360 Works sells about two dozen different FileMaker plug-ins, including:
• 360Works Email — This plug-in allows you to send and receive email messages
directly from within a database, supporting SMTP, POP, and IMAP protocols.
• 360Works Plastic — This plug-in allows credit card processing directly from within a
database supporting both Authorize.net and Verisign/PayPal Payflow.
• 360Works Web Services Manager — This plug-in publishes FileMaker scripts as
XML Web Services that can be accessed by SOAP (Simple Object Access Protocol)-
compatible software and can be used to power public Web Services.
For more information visit the 360 Works website: 360works.com.
Productive Computing
Productive Computing sells several useful FileMaker plug-ins, including:
• Address Book Manipulator — This plug-in allows bidirectional data exchange
between a database and the macOS Contacts application.
• iCal Manipulator — This plug-in allows bidirectional data exchange between a
database and the macOS Calendar application.
• File Manipulator — This plug-in allows a database to copy, rename, move, delete,
compress, and encrypt files or folders in local or networked directories.
• Biometric Fingerprint Reader — This plug-in adds the ability to incorporate
fingerprint security and script control options to a database.
For more information visit the Productive Computing website: productivecomputing.com.
Trio Automatisering
Troi Automatisering sells many different FileMaker plug-ins, including:
• Troi Dialog — This plug-in allows a database to display dynamic dialogs with an
icon, a progress bar, up to four buttons, up to fifteen input fields, and more.
• Troi File — This plug-in allows files stored anywhere in local or networked
directories to be accessed from within a database. Create files, get data from fields,
manipulate files, and more.
For more information visit the Troi Automatisering website: troi.com.
816
Chapter 38 ■ Extending Features with Plugins
Installing Plug-Ins
Every computer that will access a database that uses plug-in functions must have the plug-in installed
locally. Plug-ins installation resources can be embedded in and installed from a database file, either a
separate installer database or directly within a database solution. When purchased from a professional
developer, the plug-in will most likely be delivered to you in an installer database that you can run to
install it.
To prepare a database to install a plug-in, create a container field(s) for the plug-in file(s).
Plug-ins can only be installed if they are the correct architecture for the operating system and version
of FileMaker, so a mixed environment will require one field for each version of the plug-in. Next, create
a script that uses the Install Plug-in File script step with references to the appropriate container
field. For example:
■■Note In Windows, plug-ins will have an extension of either .fmx (32-bit version of FileMaker) or .fmx64
(64-bit version of FileMaker). In macOS, all plug-ins will have an extension of .fmplugin.
The script should check for errors to ensure that the installation process was successful. For example,
the Allow Solutions to Install Files application preference must be enabled for the script to work
(Chapter 2, “Application Preferences”) and will return an error if it is disabled. Also, it is a good idea to use
the Get ( InstalledFMPlugins ) function to confirm that the correct version of the plug-in is installed and
enabled.
817
Chapter 38 ■ Extending Features with Plugins
Figure 38-1. Plug-in functions are accessible under the External functions category of the Functions pane in
the Specify Calculation dialog
Starting in FileMaker 16, plug-ins can add new script steps that are accessible through the Script
Workspace.
Summary
In this chapter, we discussed the basic process for finding, installing, and accessing plug-ins.
818
PART VI
Sharing databases on networks increases their usefulness but also introduces a need for security.
These chapters cover the basics of network sharing, security, and some advanced analysis tools, and
how to connect with the author and find more help online.
39.
Introducing Network Sharing — Covers how to host a database on a
network for sharing in a multi-user environment.
40.
Securing Database Access — Discusses the options for configuring
security settings to control who has access to which features.
41.
Advanced Sharing and Analysis Tools — Explores the options for
analyzing a database’s structure with the Database Design Report and the
utilities available for manipulating files and creating runtime solutions.
42.
Getting Connected — A compilation of URLs from throughout the book,
various FileMaker-related resources, and the official sites for the author
and book.
CHAPTER 39
FileMaker databases are not only great tools for individuals, they can be shared across a network. Network
sharing allows multiple users to gain simultaneous access to one or more databases. Each user can view
records, perform data entry tasks, and even perform development tasks simultaneously. Networking
databases opens a new dimension for how teams collaborate and communicate.
In this chapter, we explore network sharing and discuss topics such as:
• How network sharing works
• Setting up peer-to-peer database sharing
• Using a FileMaker server
• Accessing databases from outside filemaker
User 1
Figure 39-1. A database file sitting in a shared server directory, accessed by multiple people simultaneously
will result in corruption and data loss
The correct way to share a database is to have it open and hosted by a version of FileMaker software
that allows sharing. This can be done using peer-to-peer sharing with either FileMaker Pro or FileMaker Pro
Advanced, or the preferred method of using client-server sharing with FileMaker Server.
When hosted in this manner, the physical file is installed somewhere on the host computer in a non-
shared folder, out of site from all users. The application, acting as a network host, makes the file available to
other users across the network while managing all read/write activity to the physical file itself, as shown in
Figure 39-2.
User 1
User 2
Figure 39-2. A database file hosted by a copy of FileMaker Pro running on a computer where the file is
installed but visible to the network. Users connect to the host application instead of directly to the file
When configured correctly, a user accesses a shared database through the Hosts tab of the Launch
Center, as shown in Figure 39-3, instead of through an Open File dialog as they would to open a database
file stored locally on their computer.
Peer Sharing
Server Sharing
Figure 39-3. The Launch Center showing databases shared by a peer and a server
822
Chapter 39 ■ Introducing Network Sharing
To open a database, select the appropriate host on the left and the desired file from the list on the right.
Then click Open or double-click on the file icon.
Limitations to Sharing
There are some limitations enforced by FileMaker to avoid conflicts between multiple users when working in
a hosted file. The following actions are limited to a single user at a time:
• Editing the same record.
• Modifying the same layout.
• Modifying the same script.
• Modifying any database scheme; tables, fields, relationships.
• Modifying any value list.
• Modifying any data source.
• Modifying any security access privileges.
The first three actions listed above can be undertaken at the same time if the users are each modifying
a different record, layout, or script. The remaining development actions are limited to a single user at a given
time working on anything within a specific developer dialog.
823
Chapter 39 ■ Introducing Network Sharing
Figure 39-4. The FileMaker Network Settings dialog for configuring peer-to-peer sharing
The following controls are available on the FileMaker Network Settings dialog:
1.
Network Sharing — These radio buttons are used to turn the FileMaker
application’s peer-to-peer sharing on or off.
2.
Currently open files — This area lists all the files open with the user’s copy of
FileMaker. Select a file to configure its access settings in the adjacent panel.
3.
Network access to file — This area contains the following radio buttons that
control which, if any, users can connect to the selected file remotely:
• All Users — Choose this option to allow any user to connect to the file. The
user will still be required to enter a valid username and password if security is
enabled on that database.
• Specify users by privilege set — Choose this option to select the privilege
set(s) to which a username and password must belong to connect to the file.
When first selected, a dialog will open with a list of available privilege sets. It can
be reopened later by clicking the adjacent Specify button.
• No users — Choose this option to deny all access to the selected file, that is, the
file will not be shared.
824
Chapter 39 ■ Introducing Network Sharing
4.
Don't display in Launch Center — Enabling this check box will cause the
selected shared file to not be publicly displayed in the Launch Center for remote
users. This means that any user will need to know the name and address of the
file to access it or can only access it indirectly by opening another database
containing a relationship that causes the file to open automatically.
5.
Send Message — This button opens a dialog allowing a message to be entered
and sent to all remote users of the selected database. This is helpful in the event
the host needs to close a file and warn users who are actively connected.
Once the database is configured, click OK to save the changes. From then on, anytime the user opens the
database on their local computer, it will be available to remote users across the network.
825
Chapter 39 ■ Introducing Network Sharing
Legacy License
The legacy license is a traditional, computer-centric option where a copy of the client application is
purchased for each computer upon which it will be installed. This license type applies only to copies of
FileMaker Pro and FileMaker Pro Advanced.
Once purchased and installed, the software can be used to work on databases locally or to connect to
databases hosted on a server. When connecting to a FileMaker Server, the number of legacy connections is
theoretically unlimited, except for any limitations imposed by hardware specifications, database design, or
the operating system of the host computer. However, this has only been officially tested up to 250 connections.
This license type is best suited for users who may work with databases locally outside of an office
network without access to a server or for those who just prefer the traditional licensing model. However,
using the legacy license, a user might end up purchasing multiple licenses if they typically divide the work
between an office workstation, a laptop, and a home computer. Each of these computers would require an
individual license.
For more information about legacy licensing or to make a purchase, visit the FileMaker store:
http://store.filemaker.com/legacy.
■■Note When using more than seven concurrent WebDirect users, FileMaker recommends a second
machine for web publishing, separate from the FileMaker Server. Also, the RAM and CPU requirements for the
web server increase with each block of additional users. See “Recommended Hardware Configurations for
FileMaker WebDirect” available at http://help.filemaker.com/app/answers/detail/a_id/15663.
826
Chapter 39 ■ Introducing Network Sharing
Non-Licensed Connections
When creating your own client-side connections, there are no licensing requirements besides the purchase
of a FileMaker Server.
Custom Web Publishing has a theoretical limit of 2000 concurrent connections but has only been
officially tested to 200. ODBC/JDBC clients are theoretically unlimited, but have been tested to 50
concurrent connections and may be limited by hardware and operating system.
■■Note For more detailed information than the basics described in this section, consult the FileMaker Server
product support section located at: https://www.filemaker.com/support/product/documentation.html.
827
Chapter 39 ■ Introducing Network Sharing
• To avoid corruption, the FileMaker Server folder should not be backed up with
operating system or third-party backup software, including the macOS Time
Machine. Instead, use FileMaker Server’s built-in scheduled backup feature, ideally
to a separate hard drive.
• Disable all screen savers and energy-saving hibernation or sleep features. Instead,
turning off or diming the monitor is fine.
• Either turn off indexing services such as the macOS Spotlight feature or exclude the
entire FileMaker Server folder.
• Exclude the entire FileMaker Server folder from anti-virus scans.
828
Chapter 39 ■ Introducing Network Sharing
Deploying a Server
After the installation is complete, you have the option to open the Deployment Assistant, a seven-step
dialog that will walk you through entering basic information about the deployment, including:
• Entering a user name, password, and PIN for accessing the admin console.
• Entering a server name, description, and owner information.
• Choosing to enable ODBC/JDBC and Web Publishing.
Once finished, the server will be configured and the Admin Console will be opened.
■■Note If you opted for it during the install process, a .webloc file containing a bookmark to the local host
will be found on the server computer’s desktop.
To access the console from the server computer, open a web browser and enter:
http://localhost:16001/admin-console
To access the console from another computer, open a web browser and enter either one:
https://<ServerAddress>:16000/admin-console
https://<ServerAddress>/admin-console
For example, if the server is running on a computer with an address of 10.0.1.20, it can be accessed
with one of these addresses:
https://10.0.1.20:16000/admin-console
https://10.0.1.20/admin-console
829
Chapter 39 ■ Introducing Network Sharing
Enter the administrator name and password you defined during deployment to log in and access the
Admin Console.
830
Chapter 39 ■ Introducing Network Sharing
• Admin Console
• Startup
• ODBC/JDBC
• Administrator Groups
• Connections
• Database Server — Contains various server settings divided into seven tabs:
• FileMaker Clients
• Databases
• Security
• Folders
• Logging
• Server Plug-Ins
• Directory Services
■■Note To avoid a security risk, FileMaker requires that a database file has an account and password
assigned before uploading to a server.
/Library/FileMaker Server/Data/Databases
To install files, copy them into the folder. You can create subfolders if desired and place files within
them. It is important that the files be assigned to the fmserver user and fmsadmin group.
831
Chapter 39 ■ Introducing Network Sharing
■■Caution Never open files located in the Databases folder directly with a client version of the software by
double-clicking them or choosing them in an Open File dialog, especially when they are being actively hosted
on the network. To be safe, files should first be closed and then removed from the folder before any direct
access with a client version of FileMaker.
4
2
Figure 39-6. The Upload to Filemaker Server dialog is used to copy an open database to a FileMaker Server
If you have a database file open, a dialog will inform you that it will be closed before continuing.
832
Chapter 39 ■ Introducing Network Sharing
This dialog allows you to select a FileMaker Server and sign on as an administrator using the
following controls:
1.
Hosts — This pop-up menu contains the following three options for selecting a
host category:
• Local Hosts — Choose this option to automatically search your local network
for FileMaker Servers.
• Favorite Hosts — Choose this option to display a list of FileMaker Servers that
you have entered and made favorites in the Launch Center (Chapter 2).
• Hosts Listed by LDAP — Choose this option to display a list of FileMaker
Servers from a lightweight directory access protocol server.
2.
List — This area lists all the available FileMaker Servers from the selected host
category.
3.
Host Address — This area will display the selected or manually entered FileMaker
Server’s address.
4.
Access Settings — Enter the Name and Password for the selected server’s admin
console.
5.
Next — Click this button to continue to the next step.
2 4
Figure 39-7. The second panel of the Upload to FileMaker Server dialog allows specification of which
database file(s) to upload
833
Chapter 39 ■ Introducing Network Sharing
Figure 39-8. The Change Folder dialog is used to select or create a database subfolder for the files being
uploaded to the server
4.
Automatically open databases — Enable this check box to automatically open
and host the databases on the server after the upload.
5.
Upload — Click this button to continue the process of uploading the selected
files into the desired folder on the server.
834
Chapter 39 ■ Introducing Network Sharing
2 3 4
Figure 39-9. The Manage Database menu of the Database tab of the Activity panel of the console
To access these tools, log into the Admin Console and perform the following actions:
1.
Click Activity in the panel on the left side of the window.
2.
Click on the Databases tab.
3.
Select one or more databases or folders.
4.
Click on the folder icon on the upper right of the Databases tab to reveal a
drop-down menu.
The following commands are available in this menu:
• Open — This command will open and begin hosting the selected database file(s).
• Open All — This command will open and begin hosting all files regardless of the
selection.
• Close — This command will close and cease hosting the selected database file(s).
• Close All — This command will close and cease hosting all files regardless of the
selection.
• Verify — This command will close, verify, and reopen the selected database file(s).
• Verify All — This command will close, verify, and reopen all files regardless of the
selection.
• Download Database — This command will download a copy of the selected closed
database file(s) to the local hard drive. In macOS, this feature will not work if pop-up
windows are blocked by the browser preferences!
835
Chapter 39 ■ Introducing Network Sharing
• Clear the Encryption Passwords — This command will remove the encryption
password from the selected database file(s).
• Clear All Encryption Passwords — This command will remove encryption
passwords from all databases regardless of the selection.
Figure 39-10. The Remove option is used to safely remove files from the list of available databases and place
them into a subfolder of the Databases folder for moving and copying elsewhere
Once selected, the console will present a dialog confirming that you want to continue moving the file
out of the server. If you click OK in this dialog, the file(s) will disappear from the list of available databases.
The file(s) will be placed inside of a new Removed_by_FMS subfolder within the Databases folder, which will
not be visible from within the Console. It is now safe to move or copy the file(s) out to another directory on
your server or elsewhere on the network.
836
Chapter 39 ■ Introducing Network Sharing
■■Note Back in FileMaker Server 5.5, there was a problem that would corrupt files if you shut down the
server software without first closing all databases. Due to this, as a precaution, some developers still follow that
procedure.
837
Chapter 39 ■ Introducing Network Sharing
Certain functions require authentication with the admin username and password. These prompts will
immediately follow once a command is entered. Optionally, you can include the administrator name and
password as follows:
For example, to get a list of all hosted databases in a single command line, try:
838
Chapter 39 ■ Introducing Network Sharing
The results will include a description of the command and details about the available options, as shown
in Figure 39-11.
Figure 39-11. The integrated help guide for the Close function
839
Chapter 39 ■ Introducing Network Sharing
■■Note For help setting up a FileMaker Cloud server, check out this detailed, step-by-step guide on the
beeswax.net blog: https://goo.gl/8tBKBN.
https://<HostName>.fmi.filemaker-cloud.com
For example, if the host name you assigned the server is widgetdatabases, then the URL would be:
https://widgetdatabases.fmi.filemaker-cloud.com
840
Chapter 39 ■ Introducing Network Sharing
■■Note These methods of access don’t necessarily require a FileMaker Server to work and can work with
databases open locally on a user’s computer. However, to share these with other users, the databases must be
shared either peer to peer or hosted on a server.
Figure 39-12. The dialog used to specify the location and settings when saving a snapshot link
841
Chapter 39 ■ Introducing Network Sharing
■■Caution: A user account must have explicit permission to use this feature. This is granted by the
fmurlscript extended privilege (Chapter 40).
FMP://<databaseName>.fmp12
For example, to open a Contacts database, the address would be formatted like this:
FMP://Contacts.fmp12
FMP://Learn%20FileMaker.fmp12
FMP://<serverAddress>/<databaseName>
For example, if the Learn FileMaker database were hosted on a server, the FMP URL might be:
FMP://10.1.0.10/Contacts.fmp12
The address portion of the URL can be an IPv4 address (as shown above) or it can be an IPv6 address or
DNS name as shown in these example:
FMP://[2001:0db8:0a0b:12f0:0000:0000:0000:0001]/Contacts.fmp12
FMP://filemaker.local/Contacts.fmp12
843
Chapter 39 ■ Introducing Network Sharing
To completely bypass the login dialog, an account name and password can be added as colon delimited
values ahead of the address separated by an @ sign, as shown here:
FMP://<account>:<password>@<serverAddress>/<databaseName>.fmp12
For example, if the account name is “admin” and the password is “58Jt-234,” then the following will
open the database without a password prompt:
FMP://admin:[email protected]/Contacts.fmp12
If the account name specified doesn’t exist or the password is incorrect, FileMaker will still display the
login dialog and wait for accurate credentials to be entered before proceeding.
■■Note If a database is already open on the computer, FileMaker will ignore the credentials specified in the
URL and activate the database.
FMP://<serverAddress>/<databaseName>?<scriptName>
For example, the following URL will run a script named Find All Active in a Contacts database on the
specified host computer:
FMP://10.1.0.10/Contacts.fmp12?Find%20All%20Active
■■Note The script will be executed with the privileges and limitations of the account used to open the
database, either through the URL or by a user.
FMP://<serverAddress>/<databaseName>?<scriptName>¶m=<scriptParameter>
For example, the following URL will run a script named Find All in a Contacts database on the
specified host computer and include a qualifying parameter of “Active”:
FMP://10.1.0.10/Contacts.fmp12?Find%20All¶m=Active
844
Chapter 39 ■ Introducing Network Sharing
FMP://<serverAddress>/<database>?<script>¶m=<Parameter>&<$variable>=<value>
This example shows how to initialize a variable specifying a state name for the find script:
FMP://10.1.0.10/Contacts.fmp12?Find%20All¶m=Active&$State=Pennsylvania
■■Caution: A user account must have explicit permission to use this feature. This is granted by the
fmextscriptaccess extended privilege (Chapter 40).
AppleScript is an Open Scripting Architecture compliant command language that can communicate with
and control Macintosh applications. Back in 1994 when the language was first introduced as a part of the
Macintosh System 7.5, one of the first scriptable applications was FileMaker Pro. Since then, support for the
language has steadily evovled and continues to provide a great method for accessing and manipulating data
with scripts from outside of FileMaker.
845
Chapter 39 ■ Introducing Network Sharing
Figure 39-13. The FileMaker Pro Advanced dictionary window contains definitions of all the objects and
commands available for controlling the application with AppleScript
■■Caution FileMaker’s script commands use three different words to describe a database window:
database, document, and window. While somewhat confusing, each of these can sometimes be used
interchangeably but may have a slightly different effect.
■■Note For more general information on the AppleScript language, see my book AppleScript: Developer
Reference (2010, Wiley) or visit the language guide on Apple’s website at: https://goo.gl/i70lnx.
846
Chapter 39 ■ Introducing Network Sharing
Opening a Database
There are several methods available to open a database using AppleScript, including:
• From a local directory
• From a server host using the FMP protocol
■■Tip The beginning of this tip is trying to open a URL. Seems like a coding error???
847
Chapter 39 ■ Introducing Network Sharing
Changing Layouts
To change the current layout in the window of an open database, use the show layout command. This
example will switch to the Contact layout in an open Learn FileMaker database:
Performing a Find
An AppleScript can prompt FileMaker to search for records based on a variety of criteria.
848
Chapter 39 ■ Introducing Network Sharing
The whose clause can use various operators for matching data in the field. These include:
• contains
• does not contain
• is equal to
• is not equal to
Further, the clauses can be grouped with others to form compound search criteria. For example:
Counting Records
An AppleScript can count the number of records in the found set or the total record count in a table.
In this case, since we are getting the number of records contained within the context of a window, we
don’t have to specify the table name.
In this case, since we are accessing the count of records in a table, we must specify the table name and
send the command to the database instead of the window. The code will access the table directly without
regard to context, so the the current window doesn’t have to be displaying a layout for that table.
Summary
In this chapter, we discussed the basics of sharing databases on a network and described a few methods of
accessing shared databases from outside of FileMaker.
849
CHAPTER 40
FileMaker database files can be secured by defining accounts that limit who can gain access and the actions
they can perform.
In this chapter, we review the basics of configuring database security settings, covering:
• Exploring the benefits of security
• Defining default security
• Exploring the manage security dialog
• Creating accounts
• Exploring privilege sets
• Defining extended privileges
• Controlling file access
To satisfy this requirement, every new database created by FileMaker automatically has the following
two accounts configured:
• [Guest] — Disabled by default, this account can allow a user to enter the file without
entering a user name or password. This account cannot be deleted but can be left
disabled.
• Admin — Enabled by default, this account has no password entered. However, since
the Log in using setting of the File Options dialog (Chapter 6, “Database File
Options”) is default configured to automatically enter this account when a file is
opened, it creates the illusion that new files have no access settings. In fact, new files
are bypassing the login screen by logging in as a full access user named Admin with
no password.
■■Caution When a file is configured to auto-enter a Full Access account or if Full Access accounts don’t
require a password, FileMaker Server will automatically reject and refuse to host the file due to the vunerability.
If a currently hosted file is modified to auto-enter a Full Access acount, a warning will appear informing you
that the file will not be re-hosted after the next time it is closed by the server.
Figure 40-1. A dialog warning about the lack of a password on the default full access account named Admin
Click the Set Password button to divert to the Change Password dialog to assign a password to the
Admin account or click Ignore to continue to edit security settings without assigning a password.
■■Note This dialog will reappear each time you open or close the security dialog and when you switch
modes within the window.
852
Chapter 40 ■ Securing Database Access
5
1
6
7 8
The Basic Setup version of the dialog contains the following controls:
1.
Account List — This area lists all the accounts currently defined in the file. The
check box indicates an active account. Selecting an account displays editable
details for it in the adjacent area.
2.
Account Tools — These three buttons allow the creation, duplication and
deletion of accounts in the list above.
853
Chapter 40 ■ Securing Database Access
3.
Authenticate via — This pop-up menu offers the following choices for the
selected account’s authentication method:
• FileMaker file — This option stores all the account information within the
current database file.
• External Server — This option stores only a group name and privilege set
within the database. The group name refers to an account group created on the
host computer, external to FileMaker. Any user accounts defined on the host
computer that are members of the group will be able to log into the database and
with the privilege defined in the assigned set (see “Creating External Accounts”
later in this chapter).
• Open Authorization (OAuth) Options — Several additional options allow files
hosted on a FileMaker Server to be authenticated through a third-party service
over the internet including Amazon, Google, and Microsoft Azure AD.
4.
Local Account Options — For local accounts:
• Account Name — The name of the account appears in the editable text area and
can be modified if desired.
• Password — The existence of a password for the account is indicated here, either
as a “no password” warning or a bullet-obscured password display. Click the
Change button to open the Change Password dialog.
5.
Require password change on next login — If this check box is enabled, the
next time the account is used to access the file, a dialog will open requiring the
user to authenticate with the current password and to enter a new password.
6.
Privilege Set — This pop-up menu lists all the privilege sets defined in the file.
The selected set controls the functions available to users accessing the database
with the account.
7.
Use Detailed Setup — Click this button to toggle the dialog between basic and
detailed mode.
8.
Buttons — These buttons will close the dialog:
• Cancel — This button will discard all unsaved changes and close the dialog after
a warning dialog.
• OK — This button will save changes and close the dialog after requiring that the
user enter the name and password of an account that has full access, proving
that they aren’t about to permanently lock themselves out of the file.
854
Chapter 40 ■ Securing Database Access
■■Note The remaining examples in this chapter will be described using the Detailed Setup mode.
855
Chapter 40 ■ Securing Database Access
Creating Accounts
FileMaker accounts can be created to authenticate locally or using an external server.
856
Chapter 40 ■ Securing Database Access
4.
Account Status — The new account should default to an Active status. If not,
change it.
5.
Privilege Set — This pop-up menu lists all the privilege sets defined in the file.
Since this will be an account for developers, choose [Full Access].
When finished, click the OK button to save the changes and close the Edit Account dialog. You should
see the new Developer account listed in the Manage Security dialog. Click the OK button there to save the
security settings. FileMaker will ask you to enter a full access user name and password to confirm that you
have not forgotten your password.
■■Caution Make sure that you write your password down as there is no process to recover a forgotten
password.
Once finished, close the file and then reopen it. You should see a credentials dialog like the one in
Figure 40-6.
Figure 40-6. The credentials dialog requesting an account name and password when opening a file
Type in the account name and password and click OK to open the file.
857
Chapter 40 ■ Securing Database Access
Figure 40-7. The Edit Account dialog when authenticating via an external server
858
Chapter 40 ■ Securing Database Access
4.
Under the Client Authentication heading, select FileMaker and external
server accounts from the pop-up menu.
5.
Click the Save button and sign out of the Admin Console.
Creating a Group
To create a group in macOS Sierra, follow these steps:
1.
Open the System Preferences application.
2.
Click on the Users & Groups icon.
3.
Click the lock icon to make changes. You will be asked to authenticate with
credentials for a user with administration privileges for the computer.
4.
Click the + icon to open the New Account panel and then select Group from the
pop-up menu at the top. This will change the options in the panel to those shown
in Figure 40-8.
Figure 40-8. The New Account panel of the Users & Groups section of the System Preference application
once Group is selected from the pop-up menu
859
Chapter 40 ■ Securing Database Access
5.
Enter the name of the group in the test area and click the Create Group button.
■■Caution When entering a group name, it is a good idea to always use lowercase or at least choose a
case and stick with it. Changing the case or the name of a group later may require some advanced editing of
accounts, especially depending on your version of the macOS operating system.
Creating a User
To create a user account in macOS (Sierra), follow these steps:
1.
Open the System Preferences application.
2.
Click on the Users & Groups icon.
3.
Click the lock icon to make changes. You will be asked to authenticate with
credentials for a user with administration privileges for the computer.
4.
Click the + icon to open the New Account panel and then select Sharing Only
from the pop-up menu at the top. This will change the options in the panel to
those shown in Figure 40-9.
Figure 40-9. The New Account panel of the Users & Groups section of the System Preference application
once Sharing Only is selected from the pop-up menu
860
Chapter 40 ■ Securing Database Access
■■Note The Sharing Only option will create an account for the user on the computer without creating a user
folder and is ideal to grant database access. A regular user account on the computer can be assigned to a
group if desired.
5.
Enter the Full Name, Account Name, and Password and click the Create User
button.
Figure 40-10. Once a user is assigned membership to the group, they will be able to log into the database with
their user name and password
861
Chapter 40 ■ Securing Database Access
862
Chapter 40 ■ Securing Database Access
The default configuration of the new set is essentially no access. You must assign a unique name to the
set and explicitly assign those permissions you want to allow.
Accessing Records
The records access pop-up menu on the Edit Privilege Set dialog offers the following four options:
• Create, edit, and delete in all tables — Users of the privilege set will have all
available record permissions in every table.
• Create and edit in all tables — Users of the privilege set will be limited to
creating and editing records in every table, but the Delete Record function will be
completely disabled.
• View only in all tables — Users of the privilege set will be limited to viewing
records only while the Create, Duplicate, and Delete Record functions will be
disabled.
• All no access — Users of the privilege set will have no record permissions and be
unable to see records in any table.
• Custom privileges — When none of the other options provide the level of detail
required due to the complexity of the database or the type of user, choose this option
to assign custom privileges.
863
Chapter 40 ■ Securing Database Access
2 3 4 5 6
Figure 40-12. The Custom Record Privileges dialog allows fine control of permissions for record access
customized per table
■■Note Remember, the permissions you set in this dialog affect records for only the privilege set you are
currently editing. Each set can have completely different settings.
864
Chapter 40 ■ Securing Database Access
6.
Delete — This menu contains the following options for deleting records in
the selected table(s): yes, no, or limited. This last option opens a Specify
Calculation dialog allowing the entry of a custom formula that will be used to
determine when a record can be deleted.
7.
Field Access — This menu contains the following options for field access in the
selected table(s): all, none, or limited. This last option opens a Custom Field
Privileges dialog, shown in Figure 40-13.
Figure 40-13. The Custom Field Privileges dialog is used to control the privileges of specific fields for a table
Accessing Layouts
The layouts access pop-up menu on the Edit Privilege Set dialog offers the following four options for
layout access and design capabilities:
• All modifiable — Users of the privilege set will be able to view and modify any
layout within the database.
• All view only — Users of the privilege set will be able to view any layout in the
database but be prohibited from making design changes.
865
Chapter 40 ■ Securing Database Access
• All no access — Users of the privilege set will not be able to see any layouts in the
database.
• Custom privileges — When none of the other options provides the level of detail
required due to the complexity of the database or the type of user, choose this option
to assign custom privileges.
■■Caution If a user can’t access a layout, neither can a script run from their session unless that script is
configured to run with full access.
3
4 5
Figure 40-14. The Custom Layout Privileges dialog allows fine control of permissions for individual layouts
866
Chapter 40 ■ Securing Database Access
867
Chapter 40 ■ Securing Database Access
3
4
Figure 40-15. The Custom Value List Privileges dialog allows fine control of permissions for individual
value lists
The Custom Value List Privileges dialog contains the following controls:
1.
Allow creation of new value lists — Enable this check box to allow
accounts assigned to the privilege set to create new value lists.
2.
Value Lists— This area lists every value list in the database with the current
level of access allowed. The column headings allow you to sort the list by the
values in that column, toggling between ascending and descending with each
click. Select a value list to edit its settings or choose [Any New Value List] to
define the default permission for any value lists added to the database in the
future.
3.
Select All — Click this button to select every layout in the list at once.
4.
Privileges — These radio buttons offer a choice of three access levels for the
selected value lists(s): modifiable, view only, no access.
Accessing Scripts
The scripts access pop-up menu on the Edit Privilege Set dialog offers the following four options for
value list access and editing capabilities:
• All modifiable — Users of the privilege set will be able to execute, open, view,
create, and edit all scripts within a database.
• All executable — Users of the privilege set will be limited to executing scripts
without the ability to create, view, or edit them.
868
Chapter 40 ■ Securing Database Access
• All no access — Users of the privilege set will not be able to execute any scripts or
access them in any way.
• Custom privileges — When none of the other options provide the level of detail
required due to the complexity of the database or the type of user, choose this option
to assign custom privileges.
Figure 40-16. The Custom Script Privileges dialog allows fine control of permissions for individual scripts.
The Custom Value List Privileges dialog contains the following controls:
1.
Allow creation of new scripts — Enable this check box to allow accounts
assigned to the privilege set to create new scripts.
2.
Scripts— This area lists every script in the database. The column headings allow
you to sort the list by the values in that column, toggling between ascending
and descending with each click. Select a value list to edit its settings or choose
[Any New Script] to define the default permission for any scripts added to the
database in the future.
869
Chapter 40 ■ Securing Database Access
3.
Select All — Click this button to select every script in the list at once.
4.
Privileges — These radio buttons offer a choice of three access levels for the
selected value lists(s): modifiable, executable only, no access.
• Available menu commands — While a user’s access to menu items can be influenced
by other permissions granted to the privilege set to which they are assigned, this
menu specifies a category of commands they can access. Choose from the following
options:
• All — The user will have access to the entire menu bar.
• Editing Only — The user will have access to menu commands that perform
basic editing functions.
• Minimum — The user will have access to no menu commands except for basic
functions such as open, close and create database files, window functions,
perform scripts, preferences, and help.
870
Chapter 40 ■ Securing Database Access
FileMaker defines ten default options and offers the ability to for developers to create custom extended
privileges. These are described in the next section.
871
Chapter 40 ■ Securing Database Access
• fmapp — Grants the user access to the file shared by a peer or a server using the
FileMaker Network protocol from a copy of FileMaker Pro, FileMaker Advanced, or
FileMaker Go.
• fmreauthenticate10 — When accessing a file with FileMaker Pro or FileMaker Go,
a user will have to re-authenticate after a specified number of minutes of sleep or of
using a different application.
• fmxml — Grants the user access to databases hosted by FileMaker Server from a
web browser or other application using XML Web Publishing.
• fmphp — Grants the user access to databases hosted by FileMaker Server from a
web browser or other application using PHP Web Publishing.
• fmscriptdisabled — This setting has been deprecated and will be removed soon.
• fmextscriptaccess — Grants the user to access the database with AppleScript
(macOS) and ActiveX (Windows).
• fmurlscript — Grants the user access to run a database script from a URL
(Chapter 39, “Using the FileMaker URL”).
• fmrest — Grants the user access to a database file from a Representational State
Transfer (RESTful) web service via the FileMaker Data API when hosted on a
FileMaker Server.
Each of these settings is hard-coded to a built-in FileMaker feature. Some are connected to the
FileMaker Network Settings dialog, accessed from File > Sharing menus, described in Chapter 39. For
example, if a privilege set is allowed fmapp access in the Edit Privilege Set dialog, then this privilege will
be automatically enabled in the FileMaker Network Settings dialog and vice versa.
872
Chapter 40 ■ Securing Database Access
Account(s)
Feature Group
Privilege Set(s)
Figure 40-18. Without extended privileges, a formula must directly check account(s) and/or privilege set(s) to
confirm permission
Altering the output of a calculation field based on the user’s account name can be done using a Case
statement as shown in this example:
While this approach might be fine in many circumstances, there is a major drawback when future
personnel changes occur and Tim Smith is no longer with the company or has moved on to a new role. The
problem becomes compounded with each additional object involved in the feature group, increasing the
burden and possibility of overlooking something when changing them all.
The situation can be improved slightly by comparing the user’s privilege set instead of account name, as
shown in this example:
873
Chapter 40 ■ Securing Database Access
Now, if members of the privilege set are added or removed, the formula(s) will not require a change.
However, even with this method, there is still the potential for problems.
Using an account name or privilege set for permission conditions is not as simple as indicated in these
examples. Often, you will often need to include multiple conditions. For example, since a Developer account
must be a member of the Full Access privilege set, that may need to be included in the formula, otherwise
the user would be unable to test the feature. In other situations, you will need to include the privilege sets for
users responsible for using the feature, administrators responsible for overseeing them, and developers.
Also, any future restructuring of the privilege sets will result in the same massive editing requirement
as using the account name. For example, if the members of the Finance set need to be divided between two
or more different subsets to accommodate other privilege requirements or shifts in responsibility, every
formula in the database with conditional functionality based on the privilege set will need to be modified.
This is where the benefit of using custom extended privileges become clear.
Figure 40-19. With extended privileges, a feature group checks an extended privilege with future changes to
permission easily reconfigurable security settings
In this case, the reconfiguration burden is shifted away from the potentially numerous formulas of
resources in the feature group and onto the Manage Security dialog where it is much easier to perform:
1.
The formula of the objects in the feature group contains hard-coded conditions
locked to a custom extended privilege specific to the feature.
2.
The feature’s extended privilege can be easily assigned to one or more privilege
sets by enabling a check box on either the Edit Extended Privilege or Edit
Privilege Set dialogs.
3.
User accounts are assigned a privilege set, thereby inheriting the extended
privilege to the feature group.
Using this method, all permission changes are easily adjusted within security settings.
874
Chapter 40 ■ Securing Database Access
■■Tip Choose custom extended privilege names carefully before implementing them to avoid future changes
that would require all the formulas involved to be updated, the very task we are trying to avoid in the first place.
Open the Manage Security dialog and click on the Extended Privileges tab. Then click the New
button to open a new, empty extended privilege in an Edit Extended Privilege dialog, shown in Figure 40-20.
875
Chapter 40 ■ Securing Database Access
Figure 40-21. The new InvoiceApproval extended privilege enabled on the Finance privilege set
Now, any formula that requires conditional permission can be hard-coded to the new InvoiceApproval
extended privilege, as shown here using a Case statement:
Case (
not IsEmpty (
FilterValues ( Get ( AccountExtendedPrivileges ) ; "Finance" )
) ;
"Yes" ; "No"
)
Since the Get ( AccountExtendedPrivileges ) function returns a list of all the extended privileges
that the user account’s privilege set has enabled, you must use the FilterValues function to detect a single
value within.
876
Chapter 40 ■ Securing Database Access
3 4
The following controls are available on the File Access tab of the Manage Security dialog:
1.
Require full access privileges to use references to this file —
Enable this check box to deny access to any FileMaker databases not explicitly
listed below.
2.
Files — This area lists all the files that have been granted explicit access to use
this database as an external data source.
3.
Authorize — Click this button to open a Choose File dialog and select that
FileMaker database is authorized to access the current database. You may be
required to enter credentials for an account with full access to the selected file.
4.
Deauthorize — Click this button to remove the selected database from the list of
authorized files.
5.
Reset All — Click this button to reset the ID of all the files listed and
deauthorize them and require reauthorization. This is used to ensure unique IDs
if a duplicate or clone of a file will be granted access along with the original.
Summary
In this chapter, we discussed many of the security options available to maintain secure databases.
877
CHAPTER 41
In addition to script debugging and menu customization features, the FileMaker Pro Advanced Tools menu
contains developer utilities to assist in analyzing, sharing, and securing a database.
In this chapter, we review these tools, covering:
• Database design report
• Developer utilities
1 2
The following controls are available on the Database Design Report dialog:
1.
Available Files — This area lists all the database files currently open. The
check box next to each file will be enabled by default, but can be disabled to
exclude it from the report.
2.
Include fields from tables in select file — This area lists every table
in the selected database. The check box next to each table will be enabled by
default, but can be disabled to exclude it from the report.
3.
Include in report — This area lists the optional resources that can be included
in the report. The check box next to each will be enabled by default, but can be
disabled to exclude it from the report. The available options are:
• Accounts
• Custom Menu Sets
• Custom Menus
• Data Sources
• Extended Privileges
880
Chapter 41 ■ Advanced Sharing and Analysis Tools
• File Access
• Functions
• Layouts
• Privileges
• Relationships
• Scripts
• Value Lists
4.
Report format — Select a format for the report, either HTML or XML.
5.
File handling — Enable the check box to have the report automatically open
after it is generated.
6.
Buttons — Click the OK button to generate the report and close the dialog. Click
Cancel to close the dialog without generating a report.
When clicking OK, a Save Report dialog will open asking for a name for the report and a folder directory
in which it should be saved.
881
Chapter 41 ■ Advanced Sharing and Analysis Tools
Figure 41-3. The summary page includes an overview of every database included in the report
The database design report overview page lists each database included in the report with a count of all
the resources selected for inclusion on the dialog. Each column represents one type of resource and lists the
quantity included in the report. Click these to open the database report and navigate down to that resource.
Alternatively, click on the file name to open the report from the top, as shown in Figure 41-4.
882
Chapter 41 ■ Advanced Sharing and Analysis Tools
The database report is a single scrollable page that begins by listing a summary overview of all the
resource counts and file options, and it is then divided into sections for every resource that was included.
In the sidebar on the left is a list of links that allow navigation to a specific section of the report as well as
navigating back to the summary overview.
883
Chapter 41 ■ Advanced Sharing and Analysis Tools
At its root level, the XML report folder contains the following items:
• Summary.xml — This file contains a summary of each file included in the report.
• <database>_fmp12.xml — Each database file that was included in the report will
be represented by a single XML file. These files contain all the report information in
XML format.
BaseElements
BaseElements is a great analysis tool for traversing the structure of a database. The solution is available as
either standard FileMaker files or a stand-alone runtime application for either macOS or Windows. Both
have full layout access, and you can link to BaseElements Data Tables from your database’s relationship
graph and access the information in scripts. The product includes an open source BaseElements
plug-in with many useful functions.
For more information visit: http://www.baseelements.com.
FMPerception
Geist Interactive sells a product called FMPerception, a utility for searching, analyzing, and maintaining
FileMaker databases. The product uses a progressive analysis technique to quickly provide current and
accurate information about a database’s structure. Some features include:
• Provides a high-level overview of a database and presents a “Database Report Card”
that summarizes the complexity of a database and lists any potential problems that
were detected.
• Boasts a fast DDR import process that is nearly instantaneous.
• A graphical “call chain visualization” illustrates the flow of script calls from buttons
to scripts to subscripts, helping trace the flow of complex functionality.
• Identifies layout objects that might slow down performance.
• Performs a security audit to identify vulnerabilities such as missing passwords or
scripts that run with full access privileges.
For more information visit: https://www.geistinteractive.com.
884
Chapter 41 ■ Advanced Sharing and Analysis Tools
InspectorPro
Beezwax DataTools, Inc sells a product called InspectorPro. The product is an advanced diagnostics, analysis,
and visualization tool that is optimized for FileMaker versions 12-15. The product can help you quickly
locate references and resources, boasts over 115 different areas where it normalizes analysis information,
and can even automatically detect problems with a database structure.
For more information visit: https://www.beezwax.net.
Developer Utilities
Exclusive to FileMaker Pro Advanced is a set of developer utilities that can create a customized copy of a
database with structural modifications that allow the following sharing options and enhancing security:
• Create runtime solution application(s)
• Remove admin access from files permanently
• Enable kiosk mode for non-admin accounts
• Databases must have a FileMaker file extension
• Create error log for any processing errors
• Enable database encryption (or Re-encrypt files)
• Remove database encryption
These options, which will be explained later in this chapter, can be selected separately or in unison,
although some restrictions apply.
885
Chapter 41 ■ Advanced Sharing and Analysis Tools
6 7
886
Chapter 41 ■ Advanced Sharing and Analysis Tools
3.
Rename File — This area is used to specify a name for the output that is different
from the file selected as primary. This is the recommended method for renaming
database files in a multi-file solution since it will rename the specified files and
update all external file references to them within other files.
4.
Project Folder — Click this Specify button to select a folder in which to save
the output. Enable the check box to allow FileMaker to automatically replace
existing files in the project folder with the same name as new files it is saving.
5.
Solution Options — Click this Specify button to select the desired options
that will determine the modifications to the solution files (described later in this
chapter).
6.
Load Settings — Click this button to replace the current dialog settings with
those stored in a selected file.
7.
Save Settings — Click this button to save files containing all the settings
configured in the dialog so that they can be loaded for quick reuse in the future.
8.
Buttons — Click the OK button to begin processing the files. Click Cancel to close
the dialog without performing any functions.
■■Caution The runtime application can’t access databases across the network so this option is limited to
single-user database systems.
Select the option in the Specify Solution Options dialog, as shown in Figure 41-7.
887
Chapter 41 ■ Advanced Sharing and Analysis Tools
Figure 41-7. The Specify Solution Options dialog for creating a runtime solution
888
Chapter 41 ■ Advanced Sharing and Analysis Tools
3.
Extension — The extension entered will be used on database files in place of
the standard .fmp12 to link the files to the runtime app. The default extension of
fmpur can be replaced with a custom extension if it is unique and doesn’t conflict
with other applications installed on the user’s computer.
4.
Splash Screen Options — When the runtime application is closed, a splash
screen will appear, which can be customized using the controls:
• Preview — Click this button to see a preview of the splash screen that will appear
when the runtime application is closed.
• Custom Image — Click the Specify button to select an image file to use as a
custom splash screen.
• Delay — Enter a number within the range of 2-12 to specify the number of
seconds the splash screen should remain open.
Click OK to close the Specify Solution Options dialog and return to the Developer Utilities dialog.
Then, click OK to run the utility. A folder will be created in the Project Folder containing the runtime app,
the file(s) selected, and other resources, as shown in Figure 41-8.
The folder will contain the runtime application and the database file(s) selected. Double-click the
application to launch the solution.
■■Note The application will only run on the same operating system upon which it was created.
889
Chapter 41 ■ Advanced Sharing and Analysis Tools
Figure 41-9. The error dialog when double-clicking directly on a database file that is part of a runtime solution
The problem is that the FileMaker Pro Advanced folder contains an application called Runtime located
in the following folder:
By default, any file with an extension of fmpur will automatically be linked to open with this application
and generate the error message. To change this on macOS, select all the database files and then open the
contextual menu and open the Always Open With submenu. Select the custom runtime app, as shown in
Figure 41-10.
Figure 41-10. Connecting runtime database files to automatically open with the custom runtime application
instead of FileMaker’s default
Once this process is complete the files will always open with the custom runtime application. However,
this must be performed on every computer upon which the solution will be installed.
■■Tip Using a custom extension will avoid the necessity of this extra step.
890
Chapter 41 ■ Advanced Sharing and Analysis Tools
■■Caution If you don’t provide a button on the layout that will quit the application or close the database, the
only option will be to perform a hard restart of the computer that may lead to file damage.
891
Chapter 41 ■ Advanced Sharing and Analysis Tools
■■Caution When encrypting a database, be sure to keep the password safely stored somewhere. There is no
possibility of recovery so, if you lose the password, you will be unable to access the file.
2
3
892
Chapter 41 ■ Advanced Sharing and Analysis Tools
893
Chapter 41 ■ Advanced Sharing and Analysis Tools
Summary
In this chapter, we discussed the Database Design Report and various Developer Utilities that are
available through the FileMaker Advanced Tools menu.
894
CHAPTER 42
Getting Connected
Reach out to connect with the author, other readers, and the wider FileMaker community to ask questions,
find tips, and explore other resources.
https://www.linkedin.com/in/mark-conway-munro-1521595/
For professional help with a database or workflow automation project, contact Mark through the Write
Track Media website:
http://www.wtmedia.com
Facebook https://www.facebook.com/writetrackmedia/
Twitter https://twitter.com/WriteTrackMedia
LinkedIn https://www.linkedin.com/company/1349330
http://www.learn-filemaker.com
To ask questions, chat, or share tips with the author, readers, users, and other developers, join the
Facebook group:
https://www.facebook.com/groups/LearnFileMaker/
http://www.apress.com/us/book/9781484228623
FileMaker Inc.
Keyboard shortcuts:
macOS https://www.filemaker.com/support/product/docs/12/fmp/fmp12_keys_mac.pdf
Windows https://www.filemaker.com/support/product/docs/12/fmp/fmp12_keys_win.pdf
The FileMaker website is a great place to start looking for help and information.
Home http://www.filemaker.com
Support http://www.filemaker.com/support/
Updaters http://www.filemaker.com/support/downloads/
Community https://community.filemaker.com/welcome
Solutions https://solutions.filemaker.com/made-for-filemaker
Help https://www.filemaker.com/help/16/fmp/en/
ODBC & JBDC https://fmhelp.filemaker.com/docs/16/en/fm16_odbc_jdbc_guide.pdf
SQL Reference https://fmhelp.filemaker.com/docs/16/en/fm16_sql_reference.pdf
Error Codes http://www.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help%2Ferror-
codes.html
Base Elements http://www.baseelements.com
FM Perception https://www.geistinteractive.com
Inspector Pro https://www.beezwax.net
Plug-Ins
The manufactures of the plug-ins mentioned in Chapter 38:
Troi Automatisering http://www.troi.com
Productive Computing http://www.productivecomputing.com
360 Works http://www.360works.com
Communities
Brian Dunning was the Technical Editor of FileMaker Advisor Magazine from 1997-2016. His website is a
great resource for finding all sorts of resources, custom functions, charts, and more.
https://www.briandunning.com
http://www.filemakerworld.com
896
Chapter 42 ■ Getting Connected
https://www.reddit.com/r/filemaker/
http://fmforums.com
http://filemakertalk.com
https://www.filemakermagazine.com
Technology Sites
These are the various technology sites mentioned throughout the book, summarized here for your
convenience.
For a complete list of available Unicode numbers visit:
http://www.ssec.wisc.edu/~tomw/java/unicode.html
The Internet Engineering Task Force (IETF) Request for Comment (RFC) page:
https://www.ietf.org/rfc.html
http://www.json.org
A JSON validation tool to confirm manually typed objects are formatted properly:
http://www.jsonlint.com
https://www.base64decode.org
https://en.wikipedia.org/wiki/Standard_deviation
897
Chapter 42 ■ Getting Connected
https://en.wikipedia.org/wiki/Variance
https://en.wikipedia.org/wiki/Future_value
https://en.wikipedia.org/wiki/Net_present_value
https://en.wikipedia.org/wiki/Present_value
https://en.wikipedia.org/wiki/Coordinated_Universal_Time
https://developer.apple.com/ibeacon/
https://en.wikipedia.org/wiki/Universally_unique_identifier
898
Index
A
Application preferences
application, 25
Abs function, 328 file cache settings, 26–27
Accounts, 856 general settings, 23–24
credentials dialog, 857 layout options, 25
external account layout settings, 25
authentication, 858 memory, 26
server dialog, 858 user interface options, 24
edit dialog, 856 user name, 25
external account Application programming interface (API), 13, 160
group membership, 861 Asin function, 382
groups (macOS), 859 Atan function, 382
user account, 860 Average function, 358
set password dialog, 857 with local fields, 358–359
steps, 856 with related fields, 359–360
Acos function, 381
Aggregate function reference, 357
average, 358–360 B
count, 360–361 Back-end data system, 10
list, 362–363 Base64Decode function, 343
Max function, 363–365 Base64Encode function, 344
Min function, 365–366 Base64EncodeRFC function, 344
StDev function, 367–368 BaseElements, 884
StDevP function, 369–370 Browse mode
Sum function, 370–372 container field, 42
Variance function, 372–374 database window, 48
VarianceP function, 374–376 record content area, 42
Apple, 4 status toolbar
AppleScript, 845 customization, 53–56
database, 847 default items, 50–52
dictionary, 845 toggle, 50
field value, 848 summary field, 42
find records, 848 view menu, 35
FMP protocol, 847 web viewers, 43
found set, 849 Button controls
layouts, 848 button, 621
local directory, 847 contextual menu, 628
open database, 847 icon label, 623
table, 849 labeling options, 622
tasks, 846 script, 625–627
tell FileMaker statement, 845 setup dialog, 622
Application menu, 29 single step, 624
900
■ INDEX
901
■ INDEX
902
■ INDEX
903
■ INDEX
904
■ INDEX
905
■ INDEX
906
■ INDEX
907
■ INDEX
908
■ INDEX
909
■ INDEX
910
■ INDEX
911
■ INDEX
912
■ INDEX
913
■ INDEX
914
■ INDEX
915
■ INDEX
916
■ INDEX
917