Database Reference
In-Depth Information
Figure 11-14. In the Manage Scripts window, separators just show up as scripts named “−”, but
everywhere else, they turn into proper visual separators. Here, in the Specify Script window, one
separator appears before the “Get Up” script and another appears after the highlighted “Drink a
Cup” script.
Branching with If, Else If, Else, and End If
Sometimes a script needs to take action based on certain conditions in your database. When
you send an email to a customer manually, you look him up in the Customers layout, copy
his email address and then go to your mail program to create, address, and send the email.
You'd like to add a button to the Customers layout that creates the email directly, saving you
all the trouble of copying, switching, and pasting.
The Send Email to Customer script shown in Figure 11-15 creates a new email addressed to
the current customer. But what happens if you don't have an email address for this customer?
If the Customers::Email Address field is empty , then your script tries to send an email
without a valid address through your email program, which complains mightily. Fortunately,
you can head off this problem at the pass. If the Email Address field is empty, the script
should let you know and then skip the Send Mail step entirely.
The If step is the answer; it tests a condition and can take action based on the result of its
test. Here's how to add an If step to the Send Email to Customer script:
1. In the Edit Script dialog box, create a new script called “Send Email,” and then
add the Send Mail step .
Search WWH ::




Custom Search