Skip 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.

Trouble with FMP script and Applescript interaction

Featured Replies

Hello. I have a Filemaker script which basically does two things:

1) runs a calculated applescript to create a PDF of a web page showing information specific to the record being viewed in the DB.

2) uses the Insert File script step to put the PDF into a container field.

Usually this works well. But sometimes, it takes too long to create the PDF, and step 2 gives an error saying "This file is locked or in use". When that happens, the only button in the dialog box is OK, and when the button is pressed, the script proceeds without having inserted the file. I want to prevent that from happening, but I haven't been able to find an acceptable solution.

I've tried using error capture in the FMP script, but the File In Use error seems uncapturable. (I'd have liked to trap the error and use it to trigger a delay-and-retry.)

There is a 1 second "pause" between steps 1 and 2, which could of course be increased to make sure there's plenty of time for the PDF to be created. (It'd have to be at least 5 seconds.) But considering the script will be run several thousand times, unnecessary delays add up (and frusterate/confuse end users).

Any suggestions on how I could make Filemaker wait until the PDF is created before trying to insert it?

Timing is often a problem when separate processes are doing things. Usually each one knows when it is done. So what I'd try first is to call the FileMaker script from AppleScript. Pseudo code:

get the web page, as PDF (however)

do script FileMaker script "Insert Web PDF"

It means you need to type the name of the FileMaker script, and be careful not to change the name after that. But it should help with the timing issue.

If not, there are more intense methods to check whether a file is "done being modified." But I've only had partial success with that.

  • Author

For some reason I thought that an Applescript run from within FMP couldn't script FMP. Good to know that's not the case, thanks.

The real problem though, is knowing when it's safe to proceed... having the Applescript call a FMP script just begs the question, since the Applescript doesn't know when the PDF is done being created either.

I ended up doing two loops in Applescript, the first one waiting until the file exists, and the second one checking the size of the PDF every .2 seconds until it comes up the same size as it was in the previous iteration. A little kludgy, but it works.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.