Database Reference
In-Depth Information
He then tries to paste the description in the invoice line item, only to find that the description
is gone, replaced by your script with the Customer ID. To keep from mystifying him, you
should generally avoid Cut and Copy.
Also, these steps don't work if the field isn't on the layout. People often show the customer's
name on an invoice, but not his ID . But if you remove the Customer ID field from the In-
voices layout, then any scripts that use Cut, Copy, or Paste and the Customer ID field will
break. For those reasons, the Set Field steps are almost always used to move or insert data.
Set Field
Set Field is the preferred method for editing data in a field because it works even if the
field it references isn't on the layout. Set Field replaces the contents of a field with the res-
ult of a calculation. Its two options let you specify the field to set and the calculation to use.
The calculation result has to be the same type as the field you've specified. For text, number,
date, time, and timestamp fields, Set Field is usually the step of choice: It's flexible and re-
liable, no matter what's on the layout.
TIP
As with many other FileMaker processes, be aware of context when you use a Set Field script
step. You can edit data through a relationship by using Set Field , but make absolutely certain the
context is what you intend. If you aren't careful, you can edit data in the wrong record.
Like many of the steps you've seen so far, you don't have to specify a field at all. In this
case, Set Field changes the field you're in at the moment the step runs . (This method
works only with text results; otherwise, you have to specify the field so FileMaker knows
what type you have in mind.)
Set Field 's normal behavior is to replace all the data in a field with the data in your calcu-
lation. But you can write a calculation that appends results to existing data: Just include the
field's data in the calculation. If you want to add “Esquire” to the end of the customer's last
name (in the Last Name field), then just use this calculation in your Set Field step:
Last Name & ", Esquire"
Set Field by Name
Like Go to Layout by Name , the Set Field by Name script step lets you make a single
script more flexible because you can calculate the field's name instead of “hard-coding” it in
a script. Other than that detail, though, Set Field by Name works just like its cousin Set
Field . But how do you know which version to use?
Search WWH ::




Custom Search