Filemaker - do script -command issue

Hi

Does anyone have any experience using AppleScript to launch FileMaker Pro (17) built in scripts?

I have a script within Filemaker that imports an XML file when a button is pushed. But I am trying to get AppleScript this automate so that a dropped file can launch the same Filemaker script instead.

The trouble is AppleScript does not wait for the Filemaker script to complete before proceeding to the next command.

I can get around it by a simple delay step…

tell application "FileMaker Pro Advanced"
	activate
	tell database "Test DB for Peter XML script.fmp12"
		tell current layout
			tell current record
				do script "XML Import"
				delay 5
			end tell
		end tell
	end tell
end tell

But this only works if there is no delay longer than 5 seconds and does not allow for any user interactions with the database before proceeding.

I have also tried inserting a field within Filemaker that the Filemaker script sets to “yes” when it is finished…

tell application "FileMaker Pro Advanced"
						activate
						tell database "Test DB for Peter XML script.fmp12"
							tell current layout
								tell current record
									do script "XML Import"
										repeat
											if cellValue of cell "Has XML Imported" is "Yes" then exit repeat
										end repeat
								end tell
							end tell
						end tell
					end tell

But this errors with “Error: -10011. Data is being accessed by another user, script, or transaction.” because Filemaker is still processing when AppleScript tries to access it.

Is there a way to pause the AppleScript until such time that it is prompted to continue by Filemaker?

Any help or ideas would be appreciated

Thanks

Tim

Hi. This is old but Fenton’s comments might give you some ideas:
https://fmforums.com/topic/27572-maintain-lockstep-between-applescript-and-fmp/

I think a little simplification in your script and it should work just fine. This works on my system and pauses the correct 10 seconds.

tell application "FileMaker Pro Advanced"
	activate
	do script "FindKAFrespondents"
	delay 10
	display dialog "It did it."
end tell

Model: Mac Pro (Mid 2010)
Browser: Firefox 79.0
Operating System: macOS 10.14

Thanks for your help guys. :slight_smile:

I’ll try out the ideas and post how I got on.

Tim

OK. I think I have it…

This seems to work

tell application "FileMaker Pro Advanced"
						activate
						tell database "Test DB for Peter XML script.fmp12"
							tell current layout
								tell current record
									do script "XML Import"
									repeat
										try
											if cellValue of cell "Has XML Imported" is "Yes" then exit repeat
										end try
									end repeat
								end tell
							end tell
						end tell
					end tell

The idea is to trap the error in a loop until it doesn’t error any more then exits the repeat.

Thanks guys

Tim