Field Order in FileMaker Layouts and AppleScript

This question is about FileMaker scripting, not about AppleScript in general. Background: A plug-in for some other software (“RagTime”) retrieves data from FileMaker via AppleEvents. With FileMaker 12, I have got a problem.

Imagine a simple FileMaker database “contacts” with two tables, “companies” and “employees”. There is a FileMaker layout displaying the address data for a company and in portal rows, the employees are listed.

First script example:

set fm_db to "contacts"
tell application "FileMaker Pro"
	tell window 1 of document fm_db
		set my_result to (get data of current record)
	end tell
end tell
my_result

This returns all values from the record. Fields in portal rows are returned as lists with one entry for each employee.

Second Script:

set fm_db to "contacts"
tell application "FileMaker Pro"
	tell window 1 of document fm_db
		set my_result to (get data of every cell of current record)
	end tell
end tell
my_result

This returns a list where only the first employee appears as a single entry. But there is a second difference: The first script returns the fields in the order of the geometrical arrangement in the layout (top-down, left-right). The second script seems to return the fields in the order in which they have been added to the layout.

A third script to get the field names:

set fm_db to "contacts"
tell application "FileMaker Pro"
	tell window 1 of document fm_db
		set my_result to (get name of every field)
	end tell
end tell
my_result

Now finally the problem: I need the lists of employees as in the first script and I need the field names, the values belong to. But the thirds script uses the same order as the second.

Currently I got stuck. Does any FileMaker scripter know a way to retrieve data from a window including all portal rows and to retrieve the field names in a consistent order?

(FileMaker 5 through 11 used the same order for field names as for the values in script 1.)

Sorry, if this is quite exotic. But any tip would be welcome.

Jürgen

I always get the data explicitly, by naming the cells whose contents I want. Eg:

set fielddata1 to (get data cell “fieldname1” of current record)
set fielddata2 to (get data cell “fieldname2” of current record)
etc

If I want portal row data, I usually create a calc or script in the main table that uses the List () function to get the values in the related rows as a CR-deimited list. The relationship is set to sort the way I want, so that when I get the values they are already sorted by the relationship. Concatenation of multiple fields in the related record rows is also easy this way.

The fields I want are always on the layout being addressed.

I do it explicitly this way because of the inconsistencies you have observed. HTH!