June 22, 200718 yr Newbies 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
June 22, 200718 yr Author Newbies 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.
June 22, 200718 yr 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.
June 26, 200718 yr Author Newbies Fenton: Your suggestion worked! Thanks much. What will we do without voodoo? Matt
September 25, 20196 yr Newbies 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!
Create an account or sign in to comment