Newbies MattH Posted June 22, 2007 Newbies Posted June 22, 2007 I wrote a quick applescript to upload an image to a server and then insert it into a container in a new record. I'm sure this has been done a million times by other developers, but I couldn't find an existing script. The problem is that I get an error message: filemaker got an error: Data is being accessed by another user, script, or transaction Unknown Error -10011 The error stops showing up for a while if I swivel my office chair around quickly and then scratch my head, then execute the script. Is there a good way to take the voodoo out of this? Thanks! Matt Applescript: property filepath "" property filename : "" property imagenumber : "" property serverpath : "" set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters set AppleScript's text item delimiters to {":"} tell application "FileMaker Pro Advanced" set serverpath to cell "G_serverpath" of current record set imagenumber to cell "key Primary Photo" of current record tell application "Finder" set filepath to choose file with prompt "Choose a file to import:" duplicate file filepath to serverpath set filename to last text item of (filepath as text) set the name of file (serverpath & filename) to imagenumber & "_" & filename end tell set cell "File Name" of current record to filename as text end tell set AppleScript's text item delimiters to oldDelimiters -- always restore original delimiters
Newbies MattH Posted June 22, 2007 Author Newbies Posted June 22, 2007 I ran the script from Script Editor and found that the error occurs on this line: set cell "File Name" of current record to filename as text The "File Name" field is in the active layout and has no restrictions.
Fenton Posted June 22, 2007 Posted June 22, 2007 The voodoo is that you may have had your cursor in a field when you ran the script. AppleScript is considered another user, so is blocked from editing the record which you left open. It's a good idea to put a Commit Record script step before running Perform AppleScript steps. If you set a field during the AppleScript, then put another Commit Record step after. Or use the AppleScript FileMaker command "save record," which does the same thing from AppleScript.
Newbies MattH Posted June 26, 2007 Author Newbies Posted June 26, 2007 Fenton: Your suggestion worked! Thanks much. What will we do without voodoo? Matt
Newbies PeterinJapan Posted September 25, 2019 Newbies Posted September 25, 2019 Just wanted to let you know, a random person in Japan was helped by the "save record" suggestion 12 years after this discussion! Cheers and thanks!
Recommended Posts
This topic is 1885 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now