From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer
The Set Field script step has been a fan favorite of every FileMaker developer and this particular developer is no exception. Both the Set Field and Set Field By Name script steps have the same two basic settings, what field do you want to set a value into and what is that value. The new FileMaker 10 release, Set Field By Name step allows the savvy developer to use their calculation skills to determine which field to update. This allows for more flexibility in a well crafted script and sometimes it is all about the flexibility.
What if you don’t know exactly what field you want to set in a script because the conditions of the record itself varies? If a record has this combination of values, you need to set this field. Otherwise, this other field needs to be set to something else. This type of conditional decision making happens all the time as a database solution evolves in complexity. Having the ability to use a calculation to make the decision which field to update is the new and shiny feature of the Set Field By Name script step.
SO WE HAVE TO TALK ABOUT THE POTENTIAL PROBLEM
You have created a wonderful script that is performing admirably for all your users. One day, you listen to a podcast or read an article that enlightened you to a naming convention for fields, tables and scripts that simply knocks your socks off. In the heat of development battle, you make some changes to the way your fields are named.
Now your cleverly crafted script with loads of Set Field By Name steps is likely broken to the core. It is not that it cannot be fixed but it can be an unexpected problem if you didn’t ... um ... well ... expect it.
There are techniques that we often call subroutines. The script itself does a double check to make sure it has the field names are correctly identified before applying them to a Set Field By Name command. In fact, a new FileMaker 10 function, GetFieldName can be part of that subroutine process.
The particulars of those subroutines is beyond the scope of this article but do not allow that to stop you. I hope to write more about this in the future as I explore the topic further myself. If you stumble upon a great article about the topic, please forward the link to me, won’t you?
More info about the author and FileMaker in general, contact me at firstname.lastname@example.org.
© 2009 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.