Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7136 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

We have a machine running FM 7 Pro Client, and a number of cron jobs that trigger applescripts at various times of day.

One script in particular seems to refuse to run to completion, when left to run overnight. The script always times out, and the script application cheerfully informs me that it experienced an "Object Not Found" error. However, if I manually trigger the script by hand, it works fine.

My question is this: when running an applescript under Filemaker, and you want to have a Filemaker Script called via the "Tell" command, does it matter which Filemaker DB window you are currently "in"? In other words - since the contents of the FM "Scripts" menu changes, based on which DB you are in, is it critical that you be viewing the particular DB where the FM script is located?

Would suddenly switching focus mid-applescript cause it to be unable to 'find' the FM script, and experience this error?

Thanks in advance,

AJB

Posted

Yes indeed it would matter which database you were addressing. As you say, different files have different scripts. You can address the database by name, so it sounds like that's what you should do. Then it doesn't matter which window is frontmost when the AppleScript runs.

In FileMaker 7 "database 1" or "document 1" is the first document opened that session. Yeah, that'll screw up many of your older AppleScripts. You can use "window 1" if you want the frontmost document. I believe window is document, not database, ie., the found set, not all records. But "Filemaker script" belongs to both "database" and "document," so no worries there; just stay away from using 1 with database or document unless that's what mean.

  • 2 weeks later...
Posted

So - I've been struggling with the format of the improved "Tell" command. If I wanted to specify a particular Filemaker DB window in which to call a script, would the format be:

tell application "Filemaker Pro"

show window with name "xyz"

do script "abc"

end tell

?

Thanks in advance,

AJB

Posted

I think a FileMaker script belongs to either "database" (by name), "document" (by name), or "window" (name or 1 for frontmost). So any of those will work. Of course, it depends on whether that script needs to run from a specific layout (which you should really put IN the FileMaker script itself).

A FileMaker script does not belong to a "layout" object. You cannot be in a tell layout block. This doesn't work:

tell layout "some name"

do script FileMaker script "script name"

end tell

But this works:

tell window 1

go to layout "some name"

do script FileMaker script "script name"

end tell

BTW, the complete syntax is: do script FileMaker script

Just "do script" seems to work also. I don't know if this is different in 7. One thing you don't want to do is to rename your FileMaker script after you've put its name in an AppleScript. For this reason I only use them when necessary, and write a comment warning me not to change the name.

Also, I've never used

show window 1

but it works fine. Saves a tell block. But it does not activate (come to the front); as you might (wrongly) assume from its name. You have to specifically activate FileMaker if you want it to come to the front. It might not matter if you're in a Perform AppleScript step (basically still inside FileMaker, and haven't called anyone else), but might otherwise.

Posted

OK - the following seems to work (albeit weirdly):

tell application "Filemaker Pro"

go to database "abc"

do script Filemaker script "xyz"

end tell

If the database called "abc" is open, then this works perfectly. However, just for giggles, I tried closing the "abc" database, and running the applescript again - just to see what would happen.

The applescript jumped into a different Filemaker window, and the contents of the window suddenly changed to show what looked an awful lot like the "abc" database, after the "xyz" script was called. However, the title of the window didn't change to reflect this. So - it works, but I'd better make sure that the correct windows are already open when I use this applescript.

Thanks again,

AJB

This topic is 7136 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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