Tải bản đầy đủ (.pdf) (97 trang)

filemaker pro 11 the missing manual phần 10 pps

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.25 MB, 97 trang )

795
 :  
Scripts and Security
If you want to secure a scripted process, then the extended privilege feature de-
scribed on page 788 is safer and lets you much more easily update accounts and
privilege sets.
Handling Security Errors
If your script tries to do something the person isn’t allowed to do, then FileMaker
shows the error message in Figure 18-21. If you turn error capture on in your script,
then this error doesn’t show on the screen. Instead, you can use the Get ( LastError )
function to check for an error (see page 694). That way, you can have the script dis-
play a custom message box, email you the name of the misbehaving person, or take
some other action. The most common security-related error is number 200: “Record
Access is Denied.” (If you’re interested in learning more about error codes, check out
the resources in Appendix B: FileMaker Error Codes.)
Figure 18-21:
When someone tries something your security
setup doesn’t allow, he sees this message—
even if it’s a script that’s breaking the rules.
Unfortunately, FileMaker doesn’t tell him—or
you—what the script is trying to do.
Running Scripts with Full Access Privileges
Sometimes you want the script to do its duty even though the user doesn’t have the
necessary privileges. For example, you may want to remove an accountant’s ability
to delete invoice records since she’s not supposed to delete any orders. But you may
still want to let her run a script that finds old completed invoices, exports them to an
archive, and then deletes them. Since this script is careful to delete only invoices that
are ready to go, the accountant can safely run it when necessary.
For those kinds of circumstances, FileMaker lets you specify when a script should
run with full access privileges for anyone. In other words, the script overrides the
normal restrictions you set up in the user’s privilege set. At the bottom of the Edit


Script dialog box, just turn on the “Run script with full access privileges” option.
With this option turned on, the script dutifully deletes the invoices even though
the accountant running it isn’t allowed to delete records in the Invoice or Line Item
tables with her account’s privilege set.
Even when you set a script to run with full access privileges in this way, you can still
prevent some folks from running it by switching it to “no access” in the Custom Script
Privileges window for a privilege set (page 779). You can also make the script check
for an extended privilege, and then take appropriate actions for different people.
796
FM P : T M M
Scripts and Security
Note: The Get ( PrivilegeSetName ) and Get ( ExtendedPrivileges) functions may not give you what you
expect if you use them while a script is running with [Full Access] privileges: The user’s real privileges don’t
show up; the functions return [Full Access] info instead. Use Get ( AccountPrivilegeSetName ) and Get
( AccountExtendedPrivileges ) to get info about the account that opened the file.
Managing Security with Scripts
The Edit Script window (page 417) has an entire section called Accounts. It includes
six steps that give you some control over the security system from your scripts. All
these steps require full access privileges to work. If you don’t manage a lot of ac-
counts in your database, then you might not find much use for these steps. But if
you have a large organization, or one that has lots of turnover—like a school system
that’s constantly adding new teachers or graduating a whole class of students who
no longer need access to databases for class work—these script steps can save tons
of time and effort.
Add Account
FileMaker lets you add new accounts to a database from a script—and for good
reason. If you build a system that uses several databases, and you can’t use external
authentication, then the Add Account step is your best friend. Instead of adding
each account to all your files manually, try this: Write a script that asks for the ac-
count name and password with a custom dialog box, and stores them in global fields.

Then use scripts in each file to add the same account to every file at once. When
you’re all done, be sure to clear the password from the global field to protect it from
prying eyes.
Or, if you have to populate your brand-new file with a huge number of people when
you’re first installing your database, then you save tons of time creating accounts if you
have an electronic list of user names and passwords. Import them (page 826) into a table,
and then use a looping script (page 443) to create hundreds of accounts in a few seconds.
Tip: The Add Account step lets you specify the account name and password using calculations, but you
have to select a specific privilege set for all users in the loop. If you want to script the creation of accounts
with different privilege sets, use the If/Else If steps and several copies of the Add Account step, each with a
different privilege set selected.
Delete Account
If you’re going to create accounts with a script, why not delete them, too? The Delete Ac-
count script needs only an account name—and you can supply it with a calculation. With
this script, you can build the other half of your multifile account management system.
797
 :  
Scripts and Security
Warning: If you write a script that adds or deletes accounts, then pay special attention to its security set-
tings. You can all too easily give a database the tightest security FileMaker allows, and then leave a gaping
security hole through a script. Customize privilege sets so that only you (or a trusted few) can run the
script, and don’t put it on the Scripts menu.
Reset Account Password
If lots of people use your database, then forgotten passwords will undoubtedly be-
come your worst nightmare. You could spend all day changing passwords for people.
Why not write a script that can reset a password to something generic, and then
email it to the person? If you set the script to run with full access privileges, then you
can even delegate password resetting to someone else. The Reset Account Password
step needs an account name and a new password to do its job.
Change Password

You’ll probably use this script step only in cases where you’re creating a special lay-
out that lets people who don’t have full access privileges manage security. For ex-
ample, you may have someone on staff who should be able to manage accounts, but
you don’t want him to have full access privileges. So you can build a special layout
(or two), and write scripts that run with full access privileges to manage all your
security tasks. That way, you can even do special workarounds like allowing some
members of a privilege set to change their passwords without giving this power to
each of them. To do so, you usually need a user’s table with a field that controls who
can and can’t run your Change Password script.
Enable Account
Once you’ve created a bunch of new accounts using the Add Account step, the En-
able Account step lets you turn them on and off at will. That way, you can create
accounts for, say, an entire class of students, and later turn on accounts for those
who’ve arrived on campus. This step sets the appropriate Account Status, and it
works only when there’s a valid account name that matches your script settings.
Re-Login
The most exciting step in the Accounts section is Re-Login. It provides a function
that doesn’t exist anywhere else in FileMaker. It lets you switch to a different account
without closing the file, which makes testing security settings a lot more convenient.
Instead of opening and closing the files until your mouse button wears out, just run
a Re-Login script. Add steps in the script that set global fields on pertinent layouts to
Get (AccountName) and Get (PrivilegeSet) so you can keep track of what you’re test-
ing as you re-login over and over. To get the most realistic testing conditions, make
sure your Re-login script calls any script that runs when your file opens.
798
FM P : T M M
Scripts and Security
You can also use Re-Login when someone inevitably calls you to his desk to show
you a problem in the database. Just re-login as an account with full access, and then
you can poke around and find out what’s happening on his computer. When you

re-login, you’re not just saving time by not closing and reopening the file: You can
actually work in the same window, on the same record, with the same found set and
sort order without all the trouble of recreating the situation back at your desk.
Tip: If you have a login script that changes that setup, turn on Script Debugger before you run the Re-
Login script. Then skip over the parts of the login script that would change that all-important setup.
Since you can re-login only from a script, most developers add a Re-Login script to
the Scripts menu in every database they create.
799


Sharing Data with Other
Systems
B
uilding a big database can make you feel like a slave to your computer, but the
point of a database is to let you manage information more efficiently. Nothing
shows this point better than FileMaker’s ability to pull data into your database
from various sources, and dump it back out again in assorted ways.
If you have data in almost any kind of program—spreadsheets full of figures, lists
of names and phone numbers, electronic orders in XML, folders full of pictures or
text documents—FileMaker can import it directly into your database. If your data is
already in FileMaker, then you can export it to lists, other databases, XML, or almost
any other format imaginable. FileMaker takes a wonderfully flexible approach: It
lets you handle simple imports and exports with just a click or two, and provides the
features to tackle the most complex cases as well—if you (or some hired help) are
willing to do the necessary work.
If your company uses one of the vast corporate databases—Oracle, Microsoft SQL
Server, or MySQL—FileMaker can integrate directly with them, bringing its powerful
(and easy) developer tools to bear on their complex-yet-oh-so-speedy data. You can put
your corporate SQL data right on the FileMaker layout, perform FileMaker finds, write
scripts, and even add calculation fields, all without writing a single line of SQL code.

Sharing Your Data with Others
Most database systems don’t live in a vacuum. Chances are your information is
important to someone else, or important to you somewhere else. You may want to
transfer job information to your Accounting software, or send the sales report to
your associate across town. Luckily, FileMaker provides options for getting the data
out of your database in all kinds of forms.
800
FM P : T M M
Sharing Your Data
with Others
Save/Send Records As
If your data is destined for a person (rather than some other computer program),
then you want a format that’s easy to look at and to work with on almost any com-
puter. FileMaker lets you save your data in two ubiquitous formats, an Excel spread-
sheet and a PDF document, and the unique Snapshot Link. Choose Excel if you want
to be able to work with the data (perform analysis, combine it with other data, create
graphs, and so forth). If you want the output to look just like it looks in FileMaker,
and you don’t need it to be editable, then a PDF is the perfect choice. Snapshot links
direct other FileMaker users to a particular set of records in your database.
Saving as Microsoft Excel
If people need to work with the data you send them, but they aren’t lucky enough to
have FileMaker, you can create an Excel file for them. (And presumably, if they’re
working with data, they have either Excel or a program that can open Excel spread-
sheets.) Just choose File➝Save/Send Records As➝Excel. When you do, FileMaker
shows the window in Figure 19-1.
Figure 19-1:
The Save Records As Excel
window lets you tell FileMaker
where to save the spreadsheet
file. It also gives you the option

of automatically opening the
file you’re creating, so you don’t
have to go rummaging around
your hard drive looking for it.
The Save pop-up menu lets you choose whether you want to save all the “Records
being browsed” (that is, the found set) or just the “Current record.” Turn on “Auto-
matically open file” if you want to see the spreadsheet as soon as FileMaker finishes
saving it. When you do, FileMaker automatically launches Excel and shows you the
spreadsheet. You also have the option to “Create email with file as attachment,” so
801
 :     
Sharing Your Data
with Others
it’s easy to check your work and create a quick email with the data your boss just
asked you to email her. Once you save, FileMaker creates a new email message in
your email program, attaches the spreadsheet, and opens the message so you can add
recipients, a subject, and any message you want.
If you click Options, you can set up some basic details for your new Excel file. For
example, you can choose whether you want your FileMaker field names to appear in
the first row of the spreadsheet. You can also type a worksheet name and a title, sub-
ject, and author (each of which appear in the spreadsheet in the appropriate places).
One option you don’t have is which FileMaker fields are included in the Excel file. All
the fields that appear on the layout you’re currently viewing (including merge fields)
will become columns in the Excel file.
Saving as Portable Document Format (PDF)
Just about anybody with a computer can view PDF files. With PDF, you get to choose
exactly how the data looks, since this format preserves your beautifully crafted lay-
outs. With FileMaker’s layout tools, your keen design sense, and the “Save/Send
Record as PDF” command, you could use email to distribute invoices, product cata-
logs, sales brochures, or annual reports. You can even send vision-impaired people a

file their software can read aloud. Even if all you need to do is send people data they
can see but can’t change, then a PDF file is just what the software engineer ordered.
Tip: The most common PDF viewer, Adobe Reader, is a free download at www.adobe.com/products/
acrobat/readstep2.html. Mac OS X also comes preloaded with its own PDF viewer, called Preview.
The basic choices are the same as for Excel. You choose between sending just the
current record or the whole found set. And, whether the file opens in a PDF viewer
or attaches to a new, blank email just as soon as FileMaker creates it. But behind the
Options button you find a much richer set of choices. There are three tabs—Docu-
ment (Figure 19-2), Security (Figure 19-3), and Initial View (Figure 19-4). Starting
with the Document tab, you can set:
• Title. This title isn’t the name you give the file in the dialog box. It’s an addi-
tional title that becomes part of the properties of the document. Most, but not
all, PDF viewer programs let you see a file’s properties.
• Subject. This document property helps you tell a series of similar documents
apart from each other.
• Author. This document property is usually your name, but may also be the
name of your company or department. Again, it helps you organize a bunch of
similar files.
• Keywords. Some file management programs can search these keywords to lo-
cate documents.
802
FM P : T M M
Sharing Your Data
with Others
• Compatibility. Choose from Acrobat 5, 6, or 7 and later. If you think your re-
cipient might not have the latest and greatest PDF viewer, pick a lower number.
• Number pages from. You can make a different numbering system than the one
you have in FileMaker. Keep in mind, though, if your layout displays page num-
bers in FileMaker, this setting won’t change them. You could create a document
where the PDF viewer says you’re on page 5 but the number displayed on the

page is 7.
• Include. You can set a limited page-number range with these options, so that
only a part of the found set is included in the PDF file. You may have to go to
Preview mode in FileMaker first, though, to help you set the page range properly.
Figure 19-2:
The PDF Options dialog box shows up when
you choose File➝Save/Send Records As➝PDF,
and then click Options. The Document tab lets
you add information to the PDF document.
The first four options become part of the
document’s properties, as described in the
note below.
Tip: You can see the PDF file’s Title, Subject, and Author in Adobe Acrobat’s PDF viewer’s Document
Properties Summary window. In Mac OS X’s Preview program, choose Tools➝Inspector instead.
In the Security tab (Figure 19-3), you can decide how much access you give your
recipients when they receive your file. You can choose:
• Require password to open the file. Click the checkbox to turn this option on,
and then enter a password. This checkbox is useful if you’re selling a catalog
and provide passwords only to people who’ve paid to receive it. Then, of course,
there’s the standard use; you just don’t want every Malcolm, Reese, and Dewey
poking around in your PDF files.
803
 :     
Sharing Your Data
with Others
• Require password to control printing, editing and security. Click the check-
box to turn this option on and enter a password. You might want your PDF
freely distributed, but not so freely used. If so, don’t require a password to open
the file, but lock it down so nobody without a password can use the material
without your permission. With this option checked, a whole raft of new options

becomes available. You can set:
— Printing. Choose from Not Permitted, Low Resolution (150 dpi), or High
Resolution. These options would protect photographic or other artwork
images that you want to send in a catalog but don’t want people to reprint
freely. You also may want someone to see your document onscreen, but not
print it and risk having it fall into the wrong hands.
— Editing. Although PDF files are generally considered view-only, with the
right software, they can actually be edited. If you don’t want to allow this
(or want to restrict what can be done), choose options from the Editing
pop-up menu. For example, if you’re sending a contract for review, and you
want to be sure no new clauses are snuck in while it’s away, you can choose
Not permitted.
— Enable copying of text, images and other content. With this option checked,
recipients can copy and paste material from your PDF file.
— Allow text to be read by screen reading software. This option lets people with
vision or reading problems have their screen reading programs read your
document out loud. Seems like turning this off would be pretty uncool.
Figure 19-3:
The Security tab lets you lock down your PDF
file if you need to prevent inappropriate use.
Some older PDF reading programs may not
recognize all these options. If someone’s PDF
reader doesn’t have security features, it can’t
open the PDF file at all, so your data is still
safe.
804
FM P : T M M
Sharing Your Data
with Others
Note: Looking for absolute, iron-clad control of your information? Handwrite it on paper and store it

in a secret vault. Vast amounts of money and time have been spent trying to secure digital information
from unauthorized access and reuse. Ask the record companies how that worked out for them. The old
chestnut about the lock only keeping the honest man honest applies here, too. PDF security settings are
deterrents to unwanted use of your intellectual property, but they’re all surmountable. When you use
these tools, you’re managing risk, not eliminating it.
The final tab in the PDF Options window is probably the one you’ll use the least. But
if you like to control which PDF viewer options are visible when your recipient first
opens your PDF file, then Initial View (Figure 19-4) is the panel for you:
Figure 19-4:
You get to decide what the user sees when she
first opens the PDF containing your database
info. Once again, not all these options work
in older versions of PDF software, so consider
your settings here a suggestion.
• Show. Your choices include Page Only (just the FileMaker layout, with no extra
tools or panels), Bookmarks Panel and Page, or Pages Panel and Page to offer
viewers some navigation options.
• Page Layout. Control the way the PDF viewer displays multipage documents.
If you choose Default, your recipients’ preferred view remains in force. But you
can also specify Single Page, Continuous, or Continuous-Facing.
• Magnification. Here you can define an automatic magnification as either a
fixed percentage of the document’s native size or automatically adjusted to fit
the window.
Warning: These Initial View options may or may not actually take effect, depending on what program
and what version of that program the PDF is opened with.
805
 :     
Snapshot Link
Snapshot Link
At times, collaborating with other users of the same database can get complicated.

You may answer a question by saying “go to the monthly report layout, find the
records for last May, and then sort by region,” and be met with a vacant stare. Hey,
not everyone has your FileMaker mojo! But if your colleague knows how to click,
Snapshot Links can help lead the way.
A Snapshot Link is a little package of instructions saved as a small file. Send that
file to your less-savvy colleague, and with a double-click, the database opens to the
layout and found set of records you chose.
Setting up the Snapshot Link is easy. Switch to the layout you want to share, find
and sort the records, and then select File➝Save/Send Records As➝Snapshot Link.
The Snapshot Link dialog box appears Figure 19-5, looking much like a Save dialog
box. Choose where you want to save it, whether to include the current record, or the
whole found set and if you want FileMaker to attach it to a new, outgoing email mes-
sage for you. With that, FileMaker saves a Snapshot Link file, with a .fpsl filename
extension.
Figure 19-5:
The Snapshot Link dialog box looks
suspiciously similar to any old Save
dialog box. And it does indeed save
a file, just one without any actual
data.
Snapshot Links are simply XML files that contain eight pieces of information about
your database that FileMaker uses to recreate the state of the database at the time the
Snapshot was taken.
• The paths to the database. Yes, that’s plural. The snapshot records your data-
base’s location on your hard drive, as well as any potential network paths to the
file. So long as the database is available through FileMaker Network sharing,
Snapshot Link users on your network can access it.
806
FM P : T M M
External SQL Sources

• The found set of records, listed by their internal record IDs.
• The current layout. The Snapshot link records the layout’s internal ID number,
not its name. You can rename that layout all day, but unless you delete it out-
right, the Snapshot Link is going to find it.
• View state. Whether you’re looking at the layout as a form, a list, or a table, the
link’s recipient will, too.
• Current record. If you want to draw attention to a particular record in the
found set, make sure that record is the active record when you create the link.
That record will be selected when the Snapshot Link is opened.
• Toolbar state. Either showing or not.
• Mode. Create the Snapshot Link in Preview mode and, you guessed it, that’s
what the user will see. Create it while in Browse or Layout mode, and the user
will get Browse mode. You can’t create Snapshot Links in Find mode.
• Sort Order. However you last sorted the current found set is retained.
Snapshot Links are slick, but it’s important to understand what they don’t include.
• Your last find. The Snapshot Link contains a list of record IDs. That list may
be the result of a find for every customer who bought a pogo stick, but it’s only
current at the time the Snapshot was created. If you open that snapshot in six
weeks, new pogo stick customers won’t be on the list and any deleted customers
won’t be magically restored.
• Data. Snapshot Links are instructions for FileMaker, not unlike a script. They
tell FileMaker something like “go this layout, show me records 1, 3, and 5, and
sort them by date”. They don’t possess any record data at all. When using a Snap-
shot Link, you always see the most current data.
• Privileges. Just because you can see a given layout, doesn’t mean others can. If
the recipient of your Snapshot Link lacks the database permissions to see the
layout or records specified in the link, FileMaker won’t allow it.
External SQL Sources
If you don’t know MySQL from MySpace, and have no interest in taking your hum-
ble FileMaker skills to the hard-core level of IT professionals, then feel free to skip

right past this section. But if you have to cross between these worlds or need to bring
the power and capability of industrial-grade database servers into your systems,
FileMaker’s External SQL Sources (or ESS) feature will seem like magic.
In a nutshell, you point your FileMaker database in the general direction of an Oracle,
Microsoft SQL Server, or MySQL (pronounced “my sequel”) database (hereafter
referred to as a SQL database). FileMaker then takes in information about that
database, learning all it needs to know to make those normally complicated systems
807
 :     
External SQL Sources
almost as easy to use as FileMaker. You can create table occurrences in your Rela-
tionships graph that are actually references to the tables in the SQL database. You
can draw relationship lines between SQL tables, and even between your FileMaker
tables and the SQL tables. You can create a layout based on a SQL table, drop a few
fields on the layout, and then jump to Find mode, where FileMaker searches the real
honest-to-goodness SQL data and shows you a found set of records.
POWER USERS CLINIC
Behind the Data
Snapshot Links are simply XML files. XML or eXtensible
Markup Language, is a computer language designed to
give different computer systems and programs a flexible
way to share information among one another. XML can
be very complex, but it’s also fantastically flexible. You can
muck about in a Snapshot Link’s XML code if you wish.
Just use a text editor or XML authoring program to open
a .fpsl file and you see something like this example. Even
if you don’t know XML, you can probably see that you
can change the Snapshot Link’s view by changing <view
type=”form”></view> to <view type=”list”></view>.
While changing Snapshot Link XML code can’t cause any

harm to your database, it can very easily render the Snap-
shot Link itself unusable. That’s OK, because you’re working
on a backup copy, right?
<?xml version=″1.0″ encoding=″UTF-8″?>
<fpsl>
<uistate>
<universalpathlist>
filemac:/Macintosh HD/Users/Charts.fp7
</universalpathlist>
<rows type=″nativeIDList″ rowcount=″66″
basetableid=″130″>
&#10;<![CDATA[1-66]]>&#10;
</rows>
<layout id=″6″></layout>
<view type=″form″></view>
<selectedrow type=″nativeID″ id=″1″></se-
lectedrow>
<statustoolbar visible=″True″></status-
toolbar>
<mode value=″browseMode″></mode>
<sortlist value=″True″>
<sort type=″Ascending″>
<primaryfield>
<field tableid=″1065090″
table=″Attendance″
id=″2″ name=″Facility″>
</field>
</primaryfield>
</sort>
</sortlist>

</uistate>
</fpsl>
With few exceptions, a SQL table works just like any other FileMaker table. But in-
stead of storing the data on your hard drive, the SQL database stores and manages
the data. You don’t need to know a lick of SQL programming to work with it. When
you add a record using the Records➝New Record command, FileMaker sends the
right secret code that adds the record to the SQL database. Just type in a field, and
then press Enter, and FileMaker updates the SQL database. It just doesn’t get more
seamless than this.
808
FM P : T M M
External SQL Sources
Setting Up ODBC
Before you can take advantage of ESS, you need to set up a few things. This business of
getting things installed and configured is the hardest part—and it’s not FileMaker’s
fault.
The SQL database server
First of all, you need a SQL database. To integrate as seamlessly as it does, FileMaker
needs to know exactly which database you’re using:
• Microsoft SQL Server 2008
• Microsoft SQL Server 2005
• Microsoft SQL Server 2000
• Oracle 11g
• Oracle 10g
• Oracle 9i
• MySQL 5.1 Community Edition
• MySQL 5.0 Community Edition
If your SQL database isn’t in this list, you have to upgrade or migrate to one that is.
Trying to make a different type of database work is futile—just ask someone who’s
tried. Luckily, this list represents recent versions of three very popular database sys-

tems. If you don’t have a SQL database, but you want to get one, you need to research
which is best for you. But if you just want to experiment, start with MySQL. For most
purposes (including real commercial use), it’s completely free. To get MySQL for
Mac OS X or Windows, visit www.mysql.com/ and look for the MySQL Community
Server link.
The rest of this section assumes you have a working SQL database server, and that
you have access to at least one database on that server.
Installing the ODBC driver
In order for FileMaker to communicate with the SQL database, you need an ODBC
driver. This software acts as the bridge between programs on your computer and the
SQL database server software. The driver is specific to your database server. If you’re
using Oracle, you need an Oracle ODBC driver, for instance. If you use Microsoft
Windows, this step is usually a breeze. Each of the supported SQL databases has an
ODBC driver provided by the manufacturer. Just visit their website and find out how
to get the driver you need.
Note: If you’re not sure what you need, try searching the Web for microsoft sql server odbc driver
download. The first site listed is probably the download page you need. (Substitute oracle or mysql for
microsoft sql server, as appropriate.)
809
 :     
External SQL Sources
Mac OS X users aren’t so lucky. The big database developers don’t provide free
ODBC drivers for the Mac. Instead, head over to www.actualtechnologies.com/, and
then purchase the right driver (they’re cheap and work beautifully). FileMaker, Inc.
worked directly with Actual to ensure maximum compatibility, and they provide
the drivers of choice. (For MySQL, choose the driver called ODBC Driver for Open
Source Databases.)
Once you’ve acquired the correct driver, install it on your computer. After you’ve
installed the driver, you have to configure it.
Configuring the data source

Your computer’s operating system has the ODBC system built in. You use a special
program on your computer to tell it which SQL databases you want to work with.
The configuration process is entirely different on Mac OS X and Windows, so go
directly to the section that applies to you.
Configuring data sources on Windows. You configure your Windows machine for
ODBC in the Control Panel (Start➝Control Panel). The control panel looks a little
different in various Windows versions:
• On Windows 7, look for “System and Security”. Open this category, and then
click Administrative Tools. If you don’t have “System and Security”, look for
Administrative Tools right in the Control Panel window, and then open it there.
• On Windows Vista, you may see a category called “System and Maintenance.”
Open this category, and then click Administrative Tools at the bottom of the list.
If you don’t see “System and Maintenance”, look for Administrative Tools in the
Control Panel window, and then open it there.
• On Windows XP, you may see a category called “Performance and Mainte-
nance”. Open this category, and then click Administrative Tools. If you don’t
have “Performance and Maintenance”, look for Administrative Tools right in the
Control Panel window, and then open it there.
Assuming you’ve found the Administrative Tools window, look inside it, and then
open Data Sources (ODBC). You should see something on your screen that looks like
Figure 19-6.
In this window, you add a DSN (data source name) for each SQL database you want
FileMaker to work with. A DSN can be one of two flavors: A System DSN is available
to everyone who uses your computer; and a User DSN is available only to the person
who created it. FileMaker works only with the System DSN variety, so to get started,
switch to the System DSN tab. Unfortunately, you may not have permission to define
these computer-wide data sources on your work computer. If Windows doesn’t let
you add a system DSN, contact your system administrator.
810
FM P : T M M

External SQL Sources
Figure 19-6:
The ODBC Data Source Administrator on
Windows lets you configure the SQL databases
your computer has access to. The acronym DSN
stands for Data Source Name, since you name
each data source you define here, and then
refer to it by name in FileMaker.
Once you’re on the System DSN tab, click Add. Windows shows you a list of avail-
able ODBC drivers. Select the appropriate one, and then click Finish. (Don’t get too
excited by the label on this button; you’re nowhere near finished.)
Note: You may get a little confused by the list of available drivers on Windows. First, you may see many
drivers whose names are apparently in a foreign language. Just scroll right past them. Also, you may
be tempted to select the driver called SQL Server. After all, every database FileMaker works with could
legitimately be called a SQL database server. But this driver is specifically for Microsoft SQL Server. If you
use one of the other database systems, keep looking.
From this point forward, configuration works a lot like Mac OS X. Skip ahead to
“Finishing ODBC data source configuration” below.
Configuring data sources on Mac OS X. On Mac OS X, you configure ODBC data
sources using a program called ODBC Administrator. You can find this program
in your Applications➝Utilities folder. When you launch the program, you see the
window in Figure 19-7.
When you open ODBC Administrator, first click the padlock icon in the bottom-
left corner to unlock it. Then click the System DSN tab. (FileMaker works only with
system-wide data sources.) Next, click Add. A sheet slides down showing a list of
ODBC drivers installed on your computer. Select the one you want, and then click
OK.
At this point, the exact configuration will vary based on the driver you’re using.
811
 :     

External SQL Sources
Figure 19-7:
The ODBC Admin-
istrator on Mac OS
X lets you create
ODBC data sources.
You need to log in
to your computer
as an administra-
tor to create the
kind of data source
FileMaker needs.
You also may need
to click the padlock
icon in the bottom-left
corner of this window
before you can make
changes.
Finishing ODBC data source configuration
The exact setup procedure varies with each ODBC driver, but a few things remain
constant:
• On Mac OS X, even though you’re in the System DSN tab, you have the option
of creating either a user or a system DSN. Make sure you choose system.
• Give the data source any name you like. You’ll use this name later when you
connect FileMaker to the database. But bear in mind if you change a name here,
you’ll have to update every FileMaker database that uses it or the connections
will break.
• The description isn’t important. Leave it blank, or leave a note for yourself.
• You need to know the address (IP address or host name) of the database server,
as well as a user name and password. You also need to know the name of the

database you’re connecting to (not Oracle or MySQL, but the name of the actual
database on the server, like Products or Financial).
• Your driver may ask lots of questions, but you can usually accept the pre-entered
answers for most of them. If you’re not sure, talk to your database administrator.
If you don’t have a database administrator, make friends with one.
• On the last page of the setup process, you get a chance to test data source. Click
this button—it tells you whether all the info you just entered is correct. Better to
find out now than when FileMaker gets confused later on.
Once you’re finished, you see your data source listed in the System DSN tab of your
ODBC configuration program. Go ahead and close the window. Your configuration
work is finished.
812
FM P : T M M
External SQL Sources
Connecting FileMaker to a SQL Data Source
Suppose you’ve decided to harness the power of the Web to grow your private inves-
tigation business. You hired a hotshot programmer to build you a sweet little website
that’s sure to put you at the top of the Google search results. Even better, visitors to
your website can fill out an inquiry form asking for your help. The programmer set
up the site so the form submissions go directly into a MySQL database. Now you
want to work with that data in FileMaker.
WORKAROUND WORKSHOP
The Case of the Missing Driver
A bug in the MySQL ODBC driver installer can leave your
ODBC system in a confused state where it stops showing
new ODBC drivers you’ve installed (even non-MySQL driv-
ers). If you installed your driver but it isn’t in the list, don’t
beat yourself up. You didn’t do anything wrong.
The fix requires a trip to the RegEdit program, where non-
technical folks rarely dare to tread. Luckily, the steps are

straightforward. Just follow them exactly, and you’ll be fine.
If you’re worried, show this page to your nerdiest friend (or
anyone under 20) and ask for help.
1. Run the RegEdit program.
2. On Windows 7 or Windows Vista, click the Start but-
ton and, in the search panel, type regedit. Then click
regedit.exe at the top of the Start menu. On Windows
XP, click Start➝Run, type regedit in the box that pops
up, and then click OK.
3. Choose File➝Export and save your current registry
someplace safe.
4. On the off chance you mess up here, you can restore
your old settings by running RegEdit again and using
the File➝Import command.
5. In the folder list on the left side of the window, click
the plus signs to expand each of these folders in
succession: HKEY_LOCAL_MACHINE, SOFTWARE,
ODBC, and ODBCINST.INI.
6. The Windows registry works like a hierarchy of fold-
ers, and you’re digging your way down to the thing
you need to change.
7. Select the ODBC Drivers folder inside ODBCINST.INI.
8. RegEdit fills the list on the right with what looks a lot
like the list of ODBC drivers.
At this point, you need to look for the problem. At the top of
the list on the right side, you see an entry called “(Default)”
(with parentheses and all). In the Data column for that line,
it should say “(value not set).” If the top row of the data col-
umn is empty, or has a pair of quotation marks, then you’re
a victim of the bug. Just select the “(Default)” item, and then

press the Delete key on your keyboard. The words “(value
not set)” should appear where they weren’t before.
Close RegEdit and, if prompted, agree to save the changes.
Now exit the Data Sources control panel, and then open it
again. You should see your driver.
You’ve acquired all the necessary information from the programmer, and configured
an ODBC data source. Your next step is to tell your FileMaker database about the
SQL database:
1. Open the FileMaker database you’ve been building, or download a copy from
www.missingmanuals.com/. Then choose File➝Manage➝External Data Sources.
Here’s where you tell your database about other places it can find data. You used
this same window to connect one FileMaker database to another (see page 592).
This time, though, you’re going to connect to a non-FileMaker database.
813
 :     
External SQL Sources
2. Click New.
FileMaker shows you the Edit Data Source window.
3. In the Name box, type Web Leads.
You can name the data source anything you want. This name will show up when
you’re choosing tables to add to the Relationships graph.
4. Click the ODBC radio button below the Name box.
FileMaker revamps the dialog box so it looks like the one in Figure 19-8.
5. Click Specify.
You see a list of all the system ODBC data sources defined on your computer.
6. Choose the data source you want to connect to, and then click OK.
FileMaker puts the data source name in the box next to DSN.
Figure 19-8:
When you select ODBC
as the Type for your new

data source, the Edit Data
Source window takes on a
whole new look. Instead of
just the path to a FileMaker
database, you tell FileMaker
which ODBC data source to
connect to, the user name
and password to use, and
which SQL objects you want
to see. Don’t worry if these
terms don’t make sense yet.
You’ll learn about them later
in this chapter, and many
of them don’t matter much
anyway.
814
FM P : T M M
External SQL Sources
At this point you have a decision to make. When someone opens this database, how
does it log in to the remote database? You have three options here:
• Turn on “Prompt user for user name and password” if you want people to
enter the login information when FileMaker makes the connection. This op-
tion means everyone has to log in to the SQL database every time they open
the FileMaker database (in addition to any password they need to open the
FileMaker file).
• Turn on “Specify username and password (applies to all users)” if you want
FileMaker to automatically log in to the SQL database on everyone’s behalf.
When you do, you can enter a calculation to determine either value, so you
can hard code a text value, automatically use the current user’s FileMaker ac-
count name (with the Get (AccountName) function) or any other mechanism

you need.
• If you’re using Microsoft Windows and Microsoft SQL Server, you can turn on
“Use Windows Authentication (Single Sign-on)”. This option lets FileMaker
automatically connect to the SQL database using the Windows user name and
password. Your database administrator has to configure the Windows accounts
properly for this setup to work (you can find details in the FileMaker help by
searching for “ODBC Single Sign-on”). Also, you have to get the Service Princi-
pal Name (SPN) from your database administrator.
Note: You may be wondering why you have to enter a user name and password here at all, since you
already typed them in when you created the ODBC data source. It turns out the ODBC system just really
wants that information so it can test your data source and ease configuration. It doesn’t actually use that
login info when you open the database.
In this case, turn on “Specify user name and password (applies to all users),” and
type the user name and password for your SQL database. Click OK to tell FileMaker
you’re done. Click OK again in the Manage External Data Sources window to get
back to your main database window.
Adding SQL Tables to a FileMaker Database
Your database now has a pipeline to the tables in a SQL data source. But you haven’t
told it what to do with those tables yet. Your next stop is the Relationships tab of the
Manage Database window, where you can fold the SQL database tables into your
overall system.
Choose File➝Manage➝Database, and switch to the Relationships tab. Then click
the Add Table button, just as though you were adding a normal FileMaker table oc-
currence. But this time, when the Specify Table window pops up (Figure 19-9), click
the Data Source pop-up menu, and then choose the name of your SQL data source.
815
 :     
External SQL Sources
POWER USERS’ CLINIC
Advanced ODBC Data Source Options

At the bottom of the Edit Data Source window, you see a
section labeled “Filter tables” (Figure 19-8). These settings
are entirely optional, but may prove very useful if you’re
connecting to a complex database system. These settings
tell FileMaker which tables you consider important, and
which ones it can safely ignore. Doing so means you don’t
have to look at very long lists as you build your database,
and helps FileMaker keep things running as quickly as
possible.
Database terminology is inconsistent from one system to
another. The “Filter tables” section gives you three empty
boxes to fill in, some with mysterious names. Here’s how
it shakes out:
• If you use Oracle, the Catalog box is irrelevant: leave
it empty. In the Schema box, you can enter a user
name. When you do, FileMaker will only look at
tables owned by that user.
• If you use Microsoft SQL Server, you can put the
name of a particular database in the Catalog box to
limit FileMaker to only tables in that database. If you
use schemas, or collections of tables and views, you
can also restrict FileMaker to just one schema.
• If you use MySQL, the Catalog box has no bearing on
things, so you can leave it empty. If you want to see
only tables for a particular user, enter the user name
in the Schema box.
• Whatever your database, if you care only about one
particular table, enter its name in the Table name
box. FileMaker will then show that table alone.
To the right of these three boxes, FileMaker offers three

checkboxes. In the world of SQL databases, two or three
different things act like tables.
• Tables are real honest-to-goodness tables, a lot like
their FileMaker counterpart.
• Views are sort of like smart folders in iTunes or your
mail program: They show portions of one or more
tables based on criteria defined on the database serv-
er. If you’re accessing a complex database, and you
need read-only access to a specific portion, you might
consider asking your database administrator to create
a view that includes just the data you need. This will
make things simpler for you down the road.
• System tables are tables the database system creates
itself for various purposes. (MySQL doesn’t have this
kind of table, so don’t fret about it if you’re a MySQL
user.)
Your job is to turn on the checkbox for each type you want
FileMaker to show. You can also turn off all three check-
boxes, and FileMaker will show everything it can.
If you don’t know what any of this means, try leaving every
box blank, and turning on Tables and Views. If FileMaker
takes a long time showing tables to pick from, if the table
you want isn’t in the list, or if you feel like you’re seeing
loads of tables you don’t want to see, consult your data-
base administrator for help.
The list below the pop-up menu changes to show all the available tables in the SQL
database. Choose the table you’re interested in, adjust the table name as necessary
(in the Name box at the bottom of the window), and then click OK.
Creating relationships
When you’re viewing a record from the Web Leads table, you might want FileMaker

to show you if that person is already in your Customers table. To make this possible,
you need some kind of connection between Customers and Web Leads. When you
816
FM P : T M M
External SQL Sources
add a table from an external data source, FileMaker puts a table occurrence right
on the relationship graph, so making the connection is easy. The table occurrence
looks, smells, and functions just like a FileMaker table. For example, it would make
sense to connect it to the Customers table by Email Address, since they both have
that information in common. Just drag the email_address field from the Web Leads
table to the Email Address field in the Customers table. FileMaker now knows how
they relate.
Figure 19-9:
Once you’ve worked through the complexity of ODBC configuration,
adding a table from a SQL database to your FileMaker relationships
graph works exactly the way you’d expect: simple.
You’re free to relate tables in any combination you want: Connect a FileMaker table
to a SQL table, or connect two SQL tables together. Connect a SQL table to a File-
Maker table, which then connects to another SQL table. You can even connect tables
from two different SQL databases.
Shadow tables
If you switch to the Tables tab in the Manage Database window, you may see some-
thing unexpected. FileMaker includes every SQL table you’ve added to your graph
in the Tables list (in stark contrast to tables from other FileMaker databases, which
never show in the Tables tab).
Note: No matter how many table occurrences you create for a particular SQL table, the underlying table
is listed only once. Also, SQL tables are always shown in italics so they’re easy to spot.
The italicized entry in the Tables tab is called a shadow table. In other words, it isn’t
the table. Rather, it’s a representation of the real table. It reflects information about
the real table, and even lets you add a little FileMaker magic to an otherwise bare bit

of computer science.
817
 :     
External SQL Sources
If you double-click the table (or switch to the Fields tab, and then select the table
from the Table pop-up menu), you’ll see the fields (sometimes called columns by
non-FileMaker database folks) from the SQL table listed in italics as well. You can
do certain things to these italicized fields:
• You can’t rename a field or change its type. That sort of thing is controlled on
the SQL database side of things.
• You can add a field comment if you want.
• You can click Options and set auto-enter and validation options for the field.
Remember, though, that the rules you set here apply only when you add or
edit records in FileMaker. Other systems that interact with the database are re-
stricted only by settings in the SQL database.
• You can delete a field. You’re not actually deleting the field from the SQL table.
Rather, deleting a field tells FileMaker you simply don’t want to see that field in
FileMaker anymore. (You can always get it back later by clicking the Sync but-
ton, as explained below.)
SQL databases tend to be more restrictive about acceptable values than FileMaker
itself. For instance, a text field in a SQL database usually has a maximum size that’s
relatively small, compared to FileMaker’s 2 GB field limit. If you select a field, click
the Options button, and then visit the Validation tab, here you might see that the
“Maximum number of characters” option is turned on, and you can’t turn it off.
Right by the checkbox, FileMaker also shows how many characters the field can hold.
Perhaps most important, you can add new fields to the shadow table. Specifically,
you can add unstored or global calculation fields and summary fields. Neither of
these field types work with SQL databases, but both are super important to File-
Maker developers. By adding them to the shadow table, you can treat the SQL tables
a little more like normal FileMaker tables. For example, you can add summary fields

so you can do complex reporting on the SQL data, or add a calculation field to show
a subtotal on a FileMaker layout.
Tip: Remember, the fields you add to the shadow table aren’t in the real table. They live only in FileMaker.
Finally, if the underlying SQL table changes in some way (perhaps the database ad-
ministrator added a new column you’re particularly interested in seeing), click Sync
at the top of the window. This button tells FileMaker to go back to the SQL database
and find out if any columns have been added, removed, or adjusted.
Syncing has nothing to do with the data in the database, though. FileMaker always
interacts with the SQL database directly to show up-to-the-moment data as you
perform searches or make changes. The Sync button synchronizes only the field
definitions from the SQL table.
818
FM P : T M M
External SQL Sources
Using SQL Tables
There’s no secret to using a SQL table—it works just like any other FileMaker
table. You can create a new layout to show records from the SQL table. You can view
those records in List view, Form view, or Table view. You can write scripts that loop
through SQL records, or use the “Go to Related Record” script step to find the re-
cords associated with a particular customer.
Everything you know about FileMaker still applies. But keep a few points in mind as
you develop your database around SQL tables:
• You can configure access to a SQL table using privilege sets just like any other
FileMaker table. But a privilege set can’t overrule the underlying SQL database.
If the user name and password you’re using to connect to the SQL database
don’t provide permission to delete records, FileMaker can’t delete them, no mat-
ter how hard you try. FileMaker does its best to give meaningful error messages
in such situations.
• Speaking of error messages, since SQL databases are more restrictive than File-
Maker, you may see error messages in places you wouldn’t normally expect. For

example, a Name field might be limited to 30 characters. If you try to enter more
than that, FileMaker lets you, but you can’t then commit the record. It would
be nice if FileMaker simply stopped you from typing too many letters, but it
doesn’t. It’s up to you to go back and delete enough to make it happy.
• FileMaker does some powerful computing magic to make these SQL tables
work. So if you have a large amount of data in your SQL table, FileMaker can
take a long time to show you data. Be patient and grateful for FileMaker’s efforts.
• FileMaker may have trouble performing some finds efficiently. If you include
only fields from one table in your find request, then it should move quickly. But
if you search in related fields, and there are thousands of matches in the related
table, FileMaker can take a very long time to sort things out. If you find that
SQL tables aren’t performing well, and you can’t simplify your find requests,
consider enlisting the help of a SQL expert (or learning it yourself). You may
be able to offload some of the heavy lifting to the SQL database server, where
ready access to the data makes things faster. For example, a complex find in
FileMaker could be converted to a SQL view that’s super-snappy. This same
advice applies to large summary reports. If you’re dealing with lots of records, it
may be faster to let the SQL database server calculate the subtotals and averages
for FileMaker.
You can use ESS to get direct access to enterprise data, interact with the back end
of your website, or even replace chunks of FileMaker data with a set of tables that’s
more open to other programs. This powerful feature may need a little setup and
some new expertise, but if you have big needs, it can be an incredibly powerful
option.
819
 :     
Exporting Data
Exporting Data
The “Save/Send Records As” options (page 800) make good sense when you just
want to send FileMaker data to an associate. But sometimes your recipient is a com-

puter. You may send your customer information to a mailing house to be printed on
postcards, or load it into QuickBooks. In cases like this, you export the data.
When you export data, FileMaker needs to know what data to export. You tell it with
the Export dialog box (Figure 19-10). The Table pop-up menu shows you what File-
Maker considers the current layout—in this case, People Detail. Below it, the field
list shows every field in that current layout. But click the pop-up menu, and you can
choose Current Table, which shows you all the fields in the current table, instead of
just the fields on the layout. You’re also welcome to pick other tables from the pop-
up menu and see their fields. When you choose fields from other tables, you’re still
exporting Customer records. If you include fields from other tables, FileMaker gets
the values from the first record related to each customer record.
Figure 19-10:
When FileMaker
exports the data, it
includes each field in
right-hand list in the
export file. The order
of the fields in this list
determines their or-
der in the export file,
and you can change
it by dragging fields
up or down in the
list. To add every field
in the field list to the
export order list, click
Move All. Likewise, to
remove all fields from
the export order, click
Clear All.

To choose a field for export, select it, and then click Move, or just double-click it.
FileMaker adds the field to the “Field export order” list, but doesn’t actually move it
there. Rather, the field stays in the list because you may want to export the same field
twice in the same export file. Imagine, for example, you’re creating an export file that
needs the billing address info in the first four fields and the shipping address info in
the next four fields. Since your database has only one set of address fields, you can
export them twice so the resulting file has the right number of fields. (Unfortunately,
you can’t ask FileMaker to export a blank field. If you often export to a format that
needs fields you don’t have, and leaving them blank is OK, just export an empty
global field in each one’s place.)

×