Jump to content
Server Maintenance This Week. ×

Can't Find Field Until I Complete Manual Search


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

Recommended Posts

Hi everyone,

I have an AppleScript that activates a database, runs a FM script that selects the correct layout and then the AppleScript puts a value in a FileMaker field.

However, if I don't complete a manual Find in that FM table first, the AppleScript says that it can't find the field.

The field is on the layout (I even go to a layout with ONLY that field) and once I've done some random search in a similar layout, I have no problems running the AppleScript.

Ideas? Thoughts? HELP!?

In advance, thanks for your time and help!

Link to comment
Share on other sites

I would say it's a timing issue. AppleScript keeps track of its own timing, FileMaker keeps track of its own. Actually FileMaker running AppleScript, in a Perform AppleScript step, seems to keep track pretty well; it waits for something to come back, though not necessarily for processes AppleScript starts to finish.

But AppleScript running FileMaker scripts does not wait. AppleScript will not be waiting until the FileMaker script is done. So you need to rethink your "control" process.

You could either specify the layout explicitly in the AppleScript set step; though anything else the FileMaker script was doing may not be done either.

Or, better, set the data into a FileMaker global field from AppleScript, so the FileMaker script can set it (I'm assuming the script needs to create a record or something, ie., the destination field isn't ready yet for AppleScript to set it beforehand.

Or, enmesh your AppleScript with FileMaker, so that FileMaker calls the AppleScript to finish. This may involve putting your AppleScript in FileMaker Perform AppleScript steps, or breaking your AppleScript file into 2 files. I don't know exactly why the AppleScript is outside FileMaker in the first place, so it's hard to say.

Link to comment
Share on other sites

The AppleScript grabs the subject from Mail.app, goes to a specific layout in a database (based on an FM script) places the subject into a global field and then runs another FM script that performs a search.

The applescript gets stuck when trying to put the subject into the global field. Then FM freezes for at least 2-5 minutes.

Link to comment
Share on other sites

It's hard to tell from the description. But it seems to me that there is more "passing back and forth" than is necessary. It seems that is where it is hanging up for a while (I believe AppleScript has a built-in timeout of 2 minutes; not sure; are you suppressing errors, so you're not seeing why it's hanging?).

AppleScript is capable of either specifying a layout or table, and setting up and performing a FileMaker Find. So one wonders, if you're intent on controlling this from AppleScript, why you mention 2 different FileMaker scripts in this operation.

Or, conversely, you can specify the table and set the global field while in AppleScript (easier than setting a regular field), then call the FileMaker script to go to layout and Find.

Link to comment
Share on other sites

The AppleScript grabs the subject from Mail.app, goes to a specific layout in a database (based on an FM script) places the subject into a global field and then runs another FM script that performs a search.

The applescript gets stuck when trying to put the subject into the global field. Then FM freezes for at least 2-5 minutes.

Use a table reference to put the data into the global. Then it doesn't have to be on the layout and it is a more postive way to accomplish this.

set data cell "gSomeField" of table "Contacts" to "1234"

Except I always like to do it this way to make it easier to change. In this simple script it doesn't make any difference. But if you've got a more complicated script, then having these declarations right at the top makes it easier to modify.

property targetField: "gSomeField"

property theTable: "Contacts"

set data cell targetField of table theTable to "1234"

Link to comment
Share on other sites

This topic is 5900 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.