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.

Setting Field Formulas

Featured Replies

The situation I have is an applescript that works in one db but doesn't work in a duplicate db. What the script does is set a text field showing the calculation used on a particular set of fields. I have checked and rechecked to make sure the script is the same in both db's. What am I missing?

The error I am receiving is:

Expected end of line but found identifier. (Error -2741)

Set Field Formulas FileMaker Script

Set Field ["gCounter", ""1""]

Loop

Perform Applescript [cApplescriptFieldDefinition"]

Set Field ["gCounter", "gCounter + 1"]

Exit Loop If [gCounter = 151]

End Loop

The following is the cApplescriptFieldDefinition field.

"tell application" & tquote & "FileMaker Pro" & tquote & "

Your applescript looks fine to me. I use almost the identical one in a database documentor that I built. The only thing different is that you haven't specified a database. That may cause problems if the correct database is not active.

As a suggestion, you would probably find it easier to understand and debug if you set up a template script in a global field gScriptTemplate. Use merge fields for anything that will change like this:

code:


tell database "<<MyDatabase>>" of application "FileMaker Pro"

set fieldInfo to the formula of field "<<cExport>><<gCounter>>"

set cell "<<gFieldDefinition>><<gCounter>>" to fieldInfo

end tell


Then you don't have to mess around with all the quotes in special fields. You can even include indents to make it easier to follow. This also makes it way easier to revise the script as necessary. Most importantly, it looks just like the script that you will execute, so mistakes will be more obvious.

To execute it, just set the formula for cApplescriptFieldDefinition to:

Substitute(Substitute(Substitute(Substitute(gScriptTemplate,

"<<MyDatabase>>" ,"WhateverThisDatabaseIsCalled"),

"<<cExport>>",cExport),

"<<gCounter>>",gCounter),

"<<gFieldDefinition>>",gFieldDefinition)

quote:

Originally posted by BobWeaver:

Substitute(Substitute(Substitute(Substitute(gScriptTemplate,

"<<MyDatabase>>" ,"WhateverThisDatabaseIsCalled"),

"<<cExport>>",cExport),

"<<gCounter>>",gCounter),

"<<gFieldDefinition>>",gFieldDefinition)

You can take this one step further by employing the Status(CurrentFileName) function in place of "WhateverThisDatabaseIsCalled".

Yes, as long as the database that runs the applescript is the same as the target database.

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.