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.

any way to get performScript result within Groovy script?

Featured Replies

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

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.

  • Author

Makes sense, and that's what I thought must be the case from my experiments with this.

Thanks for the details, and for the suggestions on alternative approaches.

Is their a doc or whitepaper that defines this "order of operations" that you mention?

TIA

K

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.