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

Recommended Posts

Posted

In 2013 I had great help here from Comment and others configuring native AppleScript in a FM Advanced 14.0.6 in El Capitan 10.11.6. It worked fine, and still does to this day. Unfortunately, I need to switch to the latest Mac OS and FM. For reasons I do not comprehend, the AppleScripts no longer work in the new environment. This is a non-commercial research DB, and I would very much appreciate if anyone can help me fix this. Here's the script. THANK YOU!

tell application "FileMaker Pro"

set fName to cell "tbl_Photos::UserFolderFN_Photoset" of current record

end tell

 

property ChooseFolder : "Choose Photoset Folder"

set SourceFolder to ("Server HD:Users:Shared:Modern Expert Upload") as alias

try

choose folder with prompt ChooseFolder

set TargetFolder to the result as alias

 

on error

tell application "FileMaker Pro" to do script "Layout"

activate application "FileMaker Pro"

 

return

end try

 

try

tell application "Finder"

set subFolders to every folder of entire contents of SourceFolder as alias list

 

if TargetFolder is not in subFolders then

display dialog "Please select a valid folder located ONLY in Modern Expert Upload folders." buttons {"OK"} default button 1

activate application "FileMaker Pro"

tell application "FileMaker Pro" to do script "Assign_Photoset_Folder"

else

move folder (TargetFolder) to "Server HD:Users:Shared:G_Drive:ModernExpertFolders:Photoset_folders" as alias

set y to count every file of entire contents of TargetFolder

set z to {"jpg", "jpeg", "pdf", "tiff", "tif", "png"}

set the name of folder (TargetFolder) to (fName) as text

set TargetFile to first file of TargetFolder as alias

set the clipboard to "Server HD" & (POSIX path of (TargetFolder))

tell application "FileMaker Pro" to set cell "tbl_Photos::NewFolderPath" of current record to the clipboard

tell application "FileMaker Pro" to set cell "tbl_Photos::Photo" of current record to ""

tell application "FileMaker Pro" to set cell "tbl_Photos::FolderItemsCount" of current record to ""

if name extension of TargetFile is in z then

tell application "FileMaker Pro" to set cell "tbl_Photos::Photo" of current record to TargetFile

end if

tell application "FileMaker Pro" to set cell "tbl_Photos::FolderItemsCount" of current record to y

tell application "FileMaker Pro" to do script "Layout"

end if

end tell

end try

Posted
55 minutes ago, BonB said:

the AppleScripts no longer work

So what exactly does "no longer work" mean? Do you get an error message? Do any AppleScripts work? And - first and foremost - did you allow the current account to perform Apple events in Extended Privileges?

 

Posted

Thank you!

1. Yes, fmextscriptaccess is checked on for all users.

2. Apple Script Editor gives error if 

3 hours ago, BonB said:

"tbl_Photos::UserFolderFN_Photoset"

is not on the layout. No other errors. No FM errors with same native AppleScript from same FM layout without the field, as far as I can tell.

3. No other parts of the script are functioning after

3 hours ago, BonB said:

move folder (TargetFolder) to "Server HD:Users:Shared:G_Drive:ModernExpertFolders:Photoset_folders" as alias

 

I tried to duplicate

 

3 hours ago, BonB said:

set TargetFolder to the result as alias

after moving TargetFolder. Then, the TargetFolder is renamed, but clipboard is still set to the original folder name. The only way I can reset the folder path then is to calculate FM text field holding the TargetFolder path to new path name. I'm still unable to make the photo import part work within this script.

This worked really well well in previous OS... The only other addition to the script I wanted to prevent the user from importing a folder with nested folders inside, either in AppleScript or FM, if possible...

Is there anything you can suggest? Thank you so much!!

Posted

Sorry, I don't know. The only thing that I can think of is break the script into individual parts and find out exactly where it fails.  AFAICT it's in a part that's performed by the Finder, so not really an FMP-related issue?

 

 

Posted

Thank you very much for looking at this, I really appreciate it.

  • Newbies
Posted

I recall that sometimes AppleScript will not link well with FileMaker using "current record" as a reference. The work around was to use a reference that included the table name.

 

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.