Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Applescript runs in Editor but not in FM

Featured Replies

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?

  • 3 weeks later...

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 by Guest

  • Author

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?

Did you remove the "tell FileMaker"/"end tell" as Bruce suggested?

  • Author

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.

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.

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

  • Author

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.

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

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.