Jump to content

AppleScipt bug? Can't access fields


This topic is 6883 days old. Please don't post here. Open a new topic instead.

Recommended Posts

So I think I discovered a little FileMaker / AppleScript quirk and I wanted to confirm it here. It may be very well known...

I was trying out some test scripts just to get the hang of things and I had one script that just displayed a dialog with some values from the database. My invoice database has fields for customer_id and customer_name. I could display the id, but the name kept on giving me an Object Not Found error. I finally figured out (I think) that the problem was that customer_name wasn't displayed on the layout (a calculated field - customer_name_city was).

I tried out other fields and got the same behavior: unless a field is actually displayed on the current layout it can't be accessed through AppleScript. FM7 allows us to access non-displayed fields from ScriptMaker, but I guess the same feature didn't make the cut for AppleScript. This seems like a pretty critical bug.

Link to comment
Share on other sites

Just as there are ways to do things in FileMaker, there are ways to do things in AppleScript. Actually the rules are similar. Just as you sometimes need to specify a layout, a found set, or a current record for certain operations in FileMaker, you may also need to do so in AppleScript.

It is true that AppleScript is more sensitive about having a field on the layout. It is a limitation, not a bug. As a work-around, in FileMaker you can always flip to a layout with with field, then flip back. Or, in your AppleScript, you can use "go to layout", or you can specify the layout by name that the field is on.

Or you can use the table syntax, but this is different, and may not set the correct record. For example, this sets the field "test2" in the 1st record of the 2nd table to "rats". I do not have to be in the 2nd table at the time. In fact I don't even need to have a layout for that table.

tell application "FileMaker Developer"

set cell "test2" of table 2 to "rats"

end tell

I cannot set the "current record" of a table however. Because current record is an object which only exists for a layout, not a table. If you have no layout you have no current record.

tell application "FileMaker Developer"

set cell "test2" of current record of layout "table2" to "mice"

end tell

I can also set a field that is not on a layout in a specific record if I specify which record:

tell application "FileMaker Developer"

set cell "test1" of last record of table "table2" to "mice"

end tell

This is the last record of the table, NOT of the found set. It works with a 0 found set. But it would be useful if you just created that record. Basically, table is all the records, whereas layout refers to the found set.

Similarly, cell is a FileMaker field on a single record, of either table or layout, whereas "field" is the all the records of the table, unless you specify a particular record (not "current record"). It would be like "Replace," except, once again, it works on a 0 found set, setting all records in the table.

tell application "FileMaker Developer"

set field "test1" of table "table2" to "farm"

end tell

You will find the same differences more or less between "database" on the one hand and "document" or "window" on the other.

Link to comment
Share on other sites

This topic is 6883 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.