Newbie question re: Applescript for Filemaker Database

Hello all. I have a quick question. We are running Filemaker Server at our office, and it’s currently serving three different databases. I’d like to set up a small AS that could either run at start-up or folks could click in their docks to launch the remote DBs. Following the syntax of the dictionary in Filemaker Pro, I wrote:

tell application "FileMaker Pro"
	activate
	get remote URL "FMP5://10.0.0.1/Contracts With Layouts"
end tell

Obviously, I’m not done- I’ll add a “try” statement or what have you so that if it’s not available the script can exit gracefully. The problem is, though, that the above yields the following result- the local copy of Filemaker Pro launches, opens a “remote host” window, selects and highlights the database “Contracts With Layouts” and then just sits there. I’ve tried adding “open “Contracts With Layouts”” to no avail. There are two buttons in this window, “Open” and “Cancel”, and “Open” is highlighted by default- I thought perhaps a line telling it to click the “Open” button might do the trick, but I’ve no idea what the syntax might be. Strangely, out of all the Applescripts they include with both Filemaker and Server, you’d think this would be a common request, but not one of them addresses it. I feel like I’m missing something very simple- anyone have any suggestions? TIA! :slight_smile:

I don’t think you need Applescript at all. Somewhere in Filemaker Inc’s support it tells how to do this, but it boils down to:
On a client computer, create a FM DB (“Opener.fp5”, whatever - .fp7 if appropriate)
Create a script, “Open”
Double click the script step and in the resulting dialog, click “Hosts”, then choose the served file you wish to open.
If you add other script steps, make the above step the last script step.
Go to Filemaker/Prefs/Document, and choose this script to run when the DB opens.
Put a copy of this “Opener.fp5” file on each client machine’s desktop in the dock, whatever.

HTH

Here’s what a complete FileMaker “Opener” script should look like. The main step is Open remote. The other steps are mostly to capture the error if the file is NOT available, to stop the dialog which would allow a user to wander around looking for the file in the wrong places.

The first clause, with the ModifierKeys bit, is to allow you to open the Opener file without it doing anything or closing itself (which it would do in all cases). In version 7 especially it is difficult to stop a file from running its opening routine.

This Opener script should be set, in File Options, to run when the file is launched. There should be no passwords to launch this file, launch as Guest (in 7), with no password in 6; let the main files on the host machine ask for the PW. This makes changing PW’s less of a hassle (scripted in 7 :slight_smile:

Basically the Opener file looks like an alias, works like an alias, but is not an alias; it uses FileMaker’s networking.

You can also put a splash screen if desired, if launch times are slow.

Enter Browse Mode
Go to Layout [ “Layout #1” ]
If [ Get(ActiveModifierKeys) = 12 ]

Control-Option (or Alt) stops the file from closing

Halt Script
Else
Show/Hide Status Area [ Lock; Hide ]
Freeze Window
Allow User Abort [ Off ]
Set Error Capture [ On ]
Open File [ “Clients” ]
If [ Get(LastError) <> 0 ]
Show Custom Dialog [ Title: “File Not Available”; Message: “The file is not available. Please check the server and try again.”; Buttons: “OK” ]
End If
Close File [ Current File ]
End If

Thanks so much for the input- solved the problem perfectly! (Of course, the first time around, I included “Close (Opener.fmp5)” and chose “Execute this script on open”, which neatly closes the “Opener” script- and also results in a script that can never be opened again! :slight_smile: that’s fine though- I’ve got the concept- I’d just never really thought of using a dummy DB to open another, remote DB- thanks, nice technique!

It is supposed to close itself; that step is supposed to run. That’s why the Get(ActiveModifierKeys)=12 section is at the top, which does 2 things.

First, the Option key forces the Authentication dialog, so you can enter the master password. Normally it auto-opens with the Guest PW, which is of no use when you want to set up the file.

Second, the the Control with Option (which adds up to 12) Halts the script before the “Open Remote” step, so the file just opens normally, so you can set up the open step to the host.

The tricky part is you have to hold at least Option to force the PW, but then you have to remember to hold Control-Option again, AFTER you enter the PW.

The good thing about it closing, other than it stops people from messing with it, is that it is then immediately available to run its “on open” script again, when double-clicked (just like an alias). Otherwise it’s just going to be sitting there open, but, unless you put a button to run the script on the layout, the user won’t know how to access the hosted files.

Some users close windows of files instead of using your (well-built) navigation; so you need to have an easy way for them to reconnect if they’ve closed all the windows. You should have a “Close All Files” script/button handy, in a Menu type file or table (in a hosted file), to neatly close all files on the host (not exit, we’re not Windows dorks). Then they can just double-click their Opener file on their desktop to reconnect. Very simple to use; a little tricky to set up.

The good news is that once you’ve got one of these little guys working, on one of the client machines, you can just copy it to all other client matchines of that network, as they all have the same path to the host machine. With version 7 you can see and enter the IP address of the host manually, if you know it, so you can prepare your Opener file ahead of time, on any machine.