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

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

Recommended Posts

Posted (edited)

I was hoping that within a Groovy script I could do something like this:

fmpro.performScript(fileName, scriptName, scriptParam);

result = fmpro.evaluate("Get ( ScriptResult )");

...

However, it appears that calling fmpro.performScript(...) triggers the FM script asynchronously - i.e., the FM script will be on a different thread, so the Groovy script doesn't wait for the script to complete before it continues on to the fmpro.evaluate(...). So the fmpro.evaluate of "Get ( ScriptResult )" just sets "result" to an empty value, since the FM script hasn't completed (and therefore hasn't returned its value yet).

So, that being the case, does anyone have any other suggestions on how to go about this sort of thing? Is there any way to get the fmpro.performScript(...) call to evaluate synchronously, or to wait in the Groovy script until the FM script finishes?

Edited by Guest
Posted

No, you can't do what you're trying to do for 2 reasons:

1) FileMaker cues all scripts asynchronously. There is an order of operations that all user actions get processed in, and script execution is near the end. This is why, for example, you can mess up any FileMaker script triggering plugin by modifying a field value in record 1 and then using the rolodex to flip to record 2 instead of tabbing out of the field. The plugin receives the event from FileMaker while the user is still on record 1, and it can tell FM to execute a script, but FM ignores that request until it flips to record 2, and then it will run the script, resulting in the the script executing on the wrong record.

It is of course possible to work around this problem by passing in a script parameter for which record to operate on, but that's a separate issue.

2) Get( ScriptResult ) only works for scripts, not plugins. You can not call this outside of the context of a running script. For example, if you put it in the data viewer, it will always return an empty result (unless maybe you're running in script debugger mode).

It is possible for you to trigger the FileMaker script, and when that script is done, it could then trigger some ScriptMaster function to post-process the result. This is how I would do it.

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