Skip 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.

Using AppleScript to define a field

Featured Replies

  • Newbies

I'm having trouble running a calculated Applescript to set a field.  I believe the problem is in the Applescript itself and not in the way I am using Filemaker.

 

The script step is:

 

Perform Applescript ["Set Id to do shell script " & Quote($Cut) & Quote ($tempFileName) & " set cell ID of current record to Id"]

 

Where $cut = "cut -d , -f 1 "

 

And $tempFileName = "/tmp/export.csv"

 

The quotes are not part of the variables, this is just the string used to set them. (i.e. Set Variable[$Cut; Value:"cut -d , -f 1 "])

 

The error I get is:

 

A """ can't go after this """.

 

But I can't figure out where the bad quote is.  I'm not really good with Applescript.

 

Any help would be greatly appreciated.

 

Thanks!

Two things: 
 
First, I highly recommend building your AppleScript code into a FileMaker variable named, for example, $asCode. Then, Perform AppleScript by calc on that single variable. That makes it easier to debug. 
 
Second, the quoting around the string for the do shell script command needs to be all together, rather than two separate pieces. 
 
Here's what your script builds: 
 
Set Id to do shell script "cut -d , -f 1 ""/tmp/export.csv" set cell ID of current record to Id
 
See how you have double quotes around the cut part and then new quotes around the file path? They need to be together. BUT, it is a good idea to quote filepaths using an AppleScript command that takes care of escaping anything as needed to run in a shell. You also need a line return before the "set cell" part of the script. 
 
Here's a fixed version of your calculation: 
Simple one (without using "quoted form of" - which really would be good to use, since not all paths are as simple and safe as yours here):

"set Id to do shell script " & Quote ( $Cut & $tempFileName) & "¶" &  "set cell ID of current record to Id"

 

More carefully built calc that will work for any path: 

"set Id to do shell script " & Quote ( $Cut ) & " & quoted form of " & Quote ( $tempFileName) & "¶" &  "set cell ID of current record to Id"

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.