Recognize a Filemaker Database

Hi

I have multiple Filemaker Databases open and I want to action only one database from a script. I have tried lots of different ways for Filemaker to recognise and call the database but when I want to perform a task it will default to the first database that was open!


property myfile : "Stagecoach_Data"
property mylayout : "FORM"
property images : "Laptop_images"


tell application "FileMaker Pro Advanced"
	activate
	exists database myfile
	go to layout images of database myfile
	
	set num to record 1 of document 1 of layout images of database myfile
	
end tell


This creates an error

tell application “FileMaker Pro Advanced”
activate
exists database “Stagecoach_Data”
true
go to layout “Laptop_images” of database “Stagecoach_Data”
get record 1 of document 1 of layout “Laptop_images” of database “Stagecoach_Data”
“FileMaker Pro Advanced got an error: Object not found.”

The database is clearly being recognised but when targeted for the action says it does not exist. If I change the line to


set num to record 1 of document 1

it gets data from the first opened database and not the one I am calling.

Help…

try


property myfile : "Stagecoach_Data"
property mylayout : "FORM"
property images : "Laptop_images"


tell application "FileMaker Pro Advanced"
   activate
   exists database myfile
   go to layout images of database myfile
   
   set num to record 1 of layout images of database myfile  -- no document ref needed
   
end tell

document is an object of the application not layout.

Same problem I am afraid drossi I have also tried


tell database myfile
		set num to record 1 of document 1
	end tell

and variations of it with no luck

Regards

hello,

try this…:


property db_name : "Stagecoach_Data"
property lo_pict : 2 -- the ID of the layout you want to target

tell application "FileMaker Pro Advanced"
	activate
	--name of databases
	if not (exists database db_name) then return display dialog "Database \"" & db_name & "\" not found." buttons "OK" default button 1 with icon 0
	tell database db_name
		go to
		go to layout ID lo_pict
		-- other statements...
	end tell
end tell

I have found a work around. It appears that Filemaker sees documents in the order that they were created (open). So


tell application "FileMaker Pro Advanced"
	
get name of every document
end tell

will list all open documents. The document names are the databases that are open so


property myfile : "Stagecoach_Data"
property mylayout : "FORM"
property images : "Laptop_images"


tell application "FileMaker Pro Advanced"

	tell document myfile
		go to layout images
		set num to the count of every record
	end tell
	end tell

finally works!!

Thanks for the input

There is (understandable) confusion in FileMaker’s AppleScript implementation between these 3 objects, database, document and window. Database and document have much overlap, but they are not the same. Same with document and window, though one expects that.

The main difference is that document has a “current record”, and its field objects are “cells”, whereas a database can refer to a “field”, but not a “field of current record.”

The best place to learn about this is in the file which FileMaker distributes (or used to), named Apple Events Reference.fp7. I did not get this in my FileMaker 10 Advanced installation (though I got mine from my FBA membership, so maybe that’s why). If not, it is very annoying that FileMaker would not include this must have documentation. It was included in FileMaker 9.