AnsweredAssumed Answered

AppleScript in Dialog-Style Window

Question asked by debi on Feb 13, 2019

I am having some trouble with AppleScript. I have never used AS before, and only need (right now) this little bit that I was able to find in an older version of the FileMaker solution I'm re-writing. The purpose is to examine a use-specified Finder directory (it's Mac only) and enter the folder contents into a field. I'm using v16 but users may be mixed versions 16 and 17. I'm on Sierra and they may end up being on a range of recent Mac OSs. I'm local now, but they will be hosted with FMS. In case any of that matters. They don't want to use plug-ins.


Here's the original script, except that I've changed the name of the field, and all the indenting got lost. (Does the indenting really matter?) It's all set as text in the "Perform AppleScript" script step, as Native AppleScript.


set x to (choose folder with prompt "Select the folder/disk with the output job (unstuffed)")

tell application "Finder"

set TheJob to every item of entire contents of x as list

set TheList to ""

repeat with TheFile in TheJob

set TheList to TheList & (name of TheFile) & return

end repeat

end tell


set cell "Catalog" of current record to TheList

on error

set cell "Catalog" of current record to TheList

end try


I've had it working previously. And it's still working, a bit sporatically. The errors I've received today include

AppleEvent timed out. -1712


Data is being accessed by another user, script, or transaction. -10011


After a little research, I've tried wrapping some of the script in statements like

with timeout of 300 seconds/end timeout


with transaction/end transaction.


Not sure if it matters if one of those is inside the other but, frankly, I'm not sure these are giving the best clues. The timeout error I was getting came back at me in about four seconds, far less than the two-minute default timeout I've read about.


I've got the "Allow Apple events and ActiveX to perform FileMaker operations (fmextscriptaccess)" Extended Privilege turned on for all privilege sets to use. I've played around with committing and opening the record. The field is on the layout.


I need this to work in a modal FileMaker window: I'm using a dialog window style, and really don't want to have to work around that, as it is a large part of how the interface is designed.


But, to the best of my deductions so far, it is the modal window that is messing things up. If I go to the layout directly as a Full Access user (plain window), it works. If I use it in the List view for this table, even with the field not enterable in Browse mode, it works. I am in with Full Access even when I get the errors.


Can anyone confirm that it is the dialog-style window causing this issue?


Any suggestions or other insights?