Using Object IDs for safer programming
FileMaker flexibility is completely transparent to any new user of FileMaker. Add a new field, script, layout, table or value list and you're free to rename that element at any time. It won't matter if you do, because FileMaker is using ID values to track all the objects. This happens behind the scenes.
However, if you become even slightly better at creating FileMaker solutions, you quickly dive into the power-user functions like SetFieldByName (new in FMP 10), GetField, Evaluate and others. One of the biggest gottchas can hit you in the form of passing a 'hard-coded' value within a Script Parameter.
Once you 'hard-code' any string as a reference to a FileMaker object, you can't easily rename it. Enter the use of the internal ID value instead of the name. This can be done today and is easier than you may have previously thought!
Comments
Odd behaviour?
Hi Matt,
love the idea of this but am having a problem I can't put my finger on.
object.id ( "1065269::11" ; "F" ; "" ; "" ) works as expected
object.id ( "1065264::48" ; "F" ; "" ; "" ) give no result
object.id ( "1065264" ; "T" ; "" ; "" ) works as expected
object.id ( "48" ; "F" ; "" ; "" ) works if I am on layout with tableID 1065264
The only difference is that 1065264 is a Globals table (and field ID 48 a global field) in the interface file, 1065269 is from the data file and a text field. I am using separation model.
Is there something daft I am missing?
Thanks
Tim