Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

I'm in need of a little help in translating the AppleScripts I used with FM6 to FM7.

In FM6, I used a FileMaker script that looped through the records of a database and performed an AppleScript on each record. This AppleScript would set variables to the data of various fields, and these variables would be used to tell other applications to do something. For example:

tell application "FileMaker Pro"

tell database "test.fp5"

tell current record

set myVariable to get data of cell "test data"

end tell

end tell

end tell

tell application "Finder"

--do something

end tell

This approach is no longer working for me in FM7. I've tried writing scripts in ScriptMaker that take the new structure of FM7 into account, and these work fine from within ScriptMaker. I can also do something like:

tell application "FileMaker Pro"

tell window 1

tell current record

set myVariable to get data of cell "test data"

end tell

end tell

end tell

However, I haven't been able to work out how to get at data from tables other than the current table from WITHIN FileMaker.

Any and all tips and suggestions gratefully received.

Tom

FileMaker Version: 7

Platform: Mac OS X Panther

Posted

set myVariable to get data of cell "test data" of table "test"

or

tell table "test"

tell current record

set myVariable to get data of cell "test data"

end tell...

Posted

I do it this way ???

set myVariable to cell "test data" of layout "test"

you must have a cell "test data" on a layout "test", but on my database, it works fine.

  • 3 months later...
Posted

I have also had more problems with version 7. I tried several experiments; see the attachments. Uncomment whichever script "tell block" you want to try, and comment the active one. There's several ways that work; and a few that don't.

SetFieldsonLayouts.zip

Posted

This has been discussed at length on another list. One basic distinction is between using tables vs windows/layouts. If you want to loop through records, do finds, etc. you need to use window and layout references. But with table references, you can do everything wth NO dependence on layouts.

A table reference is a reference to the graph. It has NO connection to layouts or windows and therefore any attempt to refer to layouts, windows when using a table reference will fail. Because it has no connection to a window, there is no such thing as a found set or current record. A table does not have to have a layout connected to it. As usual with FM7 table really means table occurrence; you cannot refer to a "real" table by name.

So if you want to loop through a set of records using a table reference you must first do something like collect a list of record IDs with a "whose" clause.

ID of every record of table "People" whose cell "City" of table "People" = "Seattle"

Or use a relationship:

ID of every record of table "SalesReps" whose cell "People::City" = "Seattle"

Here's an example:

tell application "FileMaker Developer"

set tableX to a reference to table "ContactsTO" of database "Interface"

set FirstName to a reference to cell "FirstName" of tableX

set recRef to a reference to (every record of tableX whose FirstName = "Sam")

set data cell "LastName" of recRef to "Johnson"

-- result: all "Sam" records get Johnson as their last name

end tell

If you are using window type references you must refer to layouts.

tell app "FileMaker Developer"

get current record of layout "Data Entry" of window 1 of database "MyDB"

get cell "FirstName" of current record of layout "Data Entry" of window 1 of database "MyDB"

end tell

This topic is 7408 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.