Here is the database manager's view of this table....
I would guess that the Msg field is not present on the current layout. FieldNames only returns the list of those fields actually present on the current layout.
LaRetta recently shared an auto-enter trick that could clear a group of fields by setting the value in another field as the "trigger" to auto-enter an empty string to clear the fields.
If ( TriggerField ; "" ; Self )
With the do not replace existing value field cleared will clear every field with this expression when you use set field to set the value of the global number field, TriggerField to True. (Then you set it to False so that new data can be entered without it being automatically cleared.)
Ok. It would help if the FieldNames Doc mentioned this. I will look up LaRetta's comment.
Quoting from FileMaker help:
Returns a list of the names of all fields on layoutName, in fileName file, separated by carriage returns."
Note that the second parameter specifies a layout name rather than a table name. I would guess that, in this case, the layout and table name is the same--something automatically produced when you define a new table in FileMaker.
Right. If you deliberately avoid creating a layout that is identical to the table name, you can use the table name in this function as if it was a layout name and FileMaker will act as if there is an invisible layout for that table that has every single field of that table.
So, if you want that method to work, you need to either:
- make sure that you have no layout named the same as its table, or
- make sure you put every field of the table (and ONLY those fields) on that layout.
Option #1 is a lot less work to keep up-to-date.
FieldNames () can be replaced with ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName =?" ; "" ; "" ; "TheTableName" ) and its not bound to context.