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

This topic is 1885 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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
Posted

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.

Posted

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.

  • 12 years later...

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