Database Reference
In-Depth Information
UP TO SPEED: INVERTING THE LOGIC
In the script you wrote on Branching with If, Else If, Else, and End If , the If script step runs the in-
dented steps only when the whole calculation evaluates to True. To figure out when that happens,
you have to deconstruct the calculation itself.
By itself, the IsEmpty() function returns True when the value you pass it is completely empty—in
other words, when the Email Address field is empty:
IsEmpty ( Customers::Email Address )
But that action doesn't help you because you want the email sent only when there is data in the
email field. If you have no email address entered, then the calculation above returns True, and
causes the Send Email step to run. If the email address field is filled in, on the other hand, then the
calculation's result is False, and FileMaker skips the Send Mail step.
This behavior is exactly the opposite of what you want. To flip the result of the calculation around,
you use the Not operator to invert the test's logic. It looks at the Boolean value to its right, and turns
a True to a False, or a False to a True. Here's the calculation you need:
Not IsEmpty ( Customers::Email Address )
You can easily tell if you've got the right construction by reading the If step like a sentence: “If not
is empty Email Address.” It may not be grammatical perfection, but it gets the logic right.
If this kind of logic makes your head spin, then you have another option. Remove the “not,” and
then switch your steps around. If you read the script in pseudo-English logic, it'd go like this: “If the
email address is empty, show a message, else send the email.” This method may not have the cool
factor of inverting a test's logic, but it's straightforward and less ambiguous.
Now your script checks to see if the Email Address field has something in it before running
off to create the email message. But what happens when you run the script and the Email Ad-
dress field is empty? Right now, nothing at all. FileMaker evaluates the If condition, sees
that it's False, and skips to the End If . There's nothing after the End If , so the script just
stops and your user waits in suspense, until he finally realizes that the requested email mes-
sage simply isn't coming and investigates the problem on his own—or chucks his computer
out the window.
In the interest of preventing property damage, your script should tell him why nothing is hap-
pening. For example, you can have your script show a message box saying, “You can't email
this customer, because there's no email address,” or whatever. That's what the Else step is
for:
1. In your script, select the Send Mail script step .
Search WWH ::




Custom Search