Digital Life Posted November 26, 2008 Posted November 26, 2008 Here's my applescript: tell application "FileMaker Pro Advanced" activate set theUID to cell "ID" of current record of document "Update Address Book" end tell tell application "Address Book" activate tell me to open location ("addressbook://" & theUID) end tell If I run this applescript in Script Editor it selects the correct person in Address Book. If I put the identical code into a "Perform AppleScript" in a Filemaker Script it selects the Address Book file but then it appears to hang or pause and the Filemaker icon on the dock starts to bounce. Now that is behaviour that suggests that there is a dialogue or message from Filemaker but when I click back on to the database there is no message and the person in Address book never gets selected. If I then run the Script Editor version it immediately selects the correct person in Address Book. Any ideas why it works in Script Editor but not in Filemaker?
bruceR Posted December 17, 2008 Posted December 17, 2008 (edited) Here's my applescript: tell application "FileMaker Pro Advanced" activate set theUID to cell "ID" of current record of document "Update Address Book" end tell tell application "Address Book" activate tell me to open location ("addressbook://" & theUID) end tell If I run this applescript in Script Editor it selects the correct person in Address Book. If I put the identical code into a "Perform AppleScript" in a Filemaker Script it selects the Address Book file but then it appears to hang or pause and the Filemaker icon on the dock starts to bounce. Now that is behaviour that suggests that there is a dialogue or message from Filemaker but when I click back on to the database there is no message and the person in Address book never gets selected. If I then run the Script Editor version it immediately selects the correct person in Address Book. Any ideas why it works in Script Editor but not in Filemaker? Drop the tell in a Filemaker perform applescsript statement: set theUID to (get data cell "ID" of current record ) open location ("addressbook://" & theUID) tell application "Address Book" to activate Edited December 17, 2008 by Guest
Digital Life Posted December 18, 2008 Author Posted December 18, 2008 Thanks Bruce but that's my problem. The script works in Script Editor but it does not work in a Filemaker 'Perform Applescript' statement. Any ideas why not?
Fitch Posted December 18, 2008 Posted December 18, 2008 Did you remove the "tell FileMaker"/"end tell" as Bruce suggested?
Digital Life Posted December 18, 2008 Author Posted December 18, 2008 Yes I did and it does not select the person in the Address Book. The script will not compile in Script Editor by the way.
Fitch Posted December 18, 2008 Posted December 18, 2008 You said before that it worked in Script Editor, so I assume you mean it fails when you remove the "tell FileMaker"/"end tell" lines. That is to be expected: Script Editor requires those lines but FileMaker requires that you omit them. To get Bruce's script to compile in Script Editor it looks like you'd need to put the first line inside the tell/end tell.
Fenton Posted December 19, 2008 Posted December 19, 2008 When you use the "tell me" phrase, it is passed to whoever is running the AppleScript; either Script Editor or FileMaker in this case. The reason you did that is because Address Book (AB) won't do the open location (no error, but it doesn't do it). Script Editor has no problem with open location. So that works. It would also work in Script Editor (without the tell me) if you just moved the open location outside the tell "AB " block. FileMaker feels the same about open location, no error, but it just doesn't do it. What works in both is to call some other application to do it, the commonest being either Finder or System Events. The following syntax will work in either Script Editor or FileMaker. (You'll need to add your FileMaker field to set the UID, I'm just getting it from AB. Apparently the open location command automatically brings the default app for the URL syntax to the front.) tell application "Address Book" set UID to id of 1st person end tell tell application "System Events" open location ("addressbook://" & UID) end tell You can use similar construction for other commands that FileMaker doesn't like, like: write file
Digital Life Posted December 19, 2008 Author Posted December 19, 2008 Fenton that works! Thanks very much. What I am trying to do is to store the Address Book ID of a person in a field in a Filemaker Pro record. Then the script I was trying to create would jump from the Filemaker Record to the correct record in Address Book. So here's my final code that with your help makes it happen: tell application "Filemaker Pro" set theUID to (get data cell "ID" of current record) end tell tell application "System Events" open location ("addressbook://" & theUID) end tell Thanks again to all.
Fenton Posted December 19, 2008 Posted December 19, 2008 This is actually the politically correct syntax. I've commented out the tell FileMaker lines. Then, if you ever need to copy/paste into Script Editor, you can just remove the comments. You can leave yours as is, but some FileMaker AppleScript experts (Jimmy Jones) say you should not have tell "FileMaker" lines unless absolutely necessary (as when nested into another app's tell block; but that is rare). --tell application "Filemaker Pro" set theUID to (get data cell "ID" of current record) --end tell tell application "System Events" open location ("addressbook://" & theUID) end tell
Recommended Posts
This topic is 6187 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 accountSign in
Already have an account? Sign in here.
Sign In Now