Getting values from FileMaker to Xcode Project

Hi Shane

Thanks for joining in on this.

My first try was

which gives

a later attempt was

which gives

I’ve taken to heart the rocommendation in your book to use the log command extensively for debugging. The code as it currently appears in Xcode:

tell application "FileMaker Pro" to tell database theTargetDatabase
		tell table "MailMessages"
			set theRecord to create new record
				tell current application to log "record created"  --> works to here
			set theRecordID to cell "RecordID" of theRecord
				tell current application to log "RecordID obtained"
		end tell
end tell

Running this I do get a new record in FileMaker and a log entry in Xcode but then it stalls with an error, “Object not found” in this case, and no further log entries. I agree that the problem might not necessarily be with the “set theRecordID.” command itself but I’m stumped as to why the script stops there.

Any pointers would be greatly appreciated.

I haven’t done anything with FileMaker for a long time. What happens if you ask for “cellValue of cell “RecordID” of theRecord” or “formula of cell “RecordID” of theRecord”?

“Object not found” in both cases.

What happens if you try to get the cellValue of a cell that already exists? Say, of record 1?

Pointing to an existing record I get “Object or property is the wrong type” when I reference either a numeric or text field in FileMaker.
As this is the first instance of theRecordID it has not got a property statement at the start of the script, but even when I add “property theRecordID : 0” or “property theRecordID : “”” the error message remains the same.

(Signing off 3:06 UK time).

After breakfast: are you editing the script within Xcode or a script editor?

I’m thinking about an ugly way but that worked for me in similar case (not with FM though):
Since Xcode can retrieve the full record as log, put it in a variable and coerce it as list,
then go through the var to pick out the right item (property) you need?

Shane - script editing all within Xcode.
Joseph - Nice idea. I don’t know how to implement that but will have a look.

Try selecting the file and choosing File → Open in External Editor. That should open it in Script Editor. Compile it there, and see if you spot anything odd happening with terminology.

Script compiles with no issues in Script Editor.

Although I do have breaking news. I have copied the project to another machine that has OS X 10.8.5, Xcode 5, FMP11. The only difference being FMP13 on first machine (which also has FMP9).
Application runs correctly on 2nd machine with Debug and Release builds but if I run the built product back on the first machine it appears to stop at the same point. This has really confused me.

I’ve run all OS updates and done new installs of Xcode and FMP. Each time “set theRecordID to cell “RecordID” of theRecord” works fine from AppleScript Editor but not from Xcode or the app…

I hope I have described things clearly. Might there be something missing from the first machine?

Could both versions of FM be running? I’ve had the same thing happen with other apps – running an app that targets them from Xcode results in a different version launching.

If I lauch FMP in advance and open the target database then Xcode doesn’t try to open the other.

The version of the commad that gives “Can’t make «class ccel» “RecordID” of «class crow» id 3.2818E+4 of window “Email Archive” of application “FileMaker Pro” into type integer.” makes me believe that Xcode is addressing the right field in the right database.

I’ve uninstalled FMP13 as the earlier version does communicate properly with the older version of the app.

So what code was trying to do that coercion?

set theRecordID to cell “RecordID” of theRecord as integer

when I try it without coercion I get a FileMaker error: “Object not found.”

I think I’m stumped at this point…

Ha! Join the club. Thank you so much for your input though.

I’ll try to give Joseph’s suggestion a go, failing that I’m going to use an old machine to make my script updates to the old app in Xcode 3 using pure AppleScript. Yuk!!

Before you dive in it, may I suggest you try thoroughly parenthesis usage in your code?

a few tries with different position, like this for example


set theRecordID to (cell "RecordID" of theRecord) as integer

Xcode is very touchy about syntax while AppleScript editor passes trough

an example I discovered after a good headache
set text item delimiters to “:” runs in AS editor
and likely fails in Xcode because the original syntax is
set AppleScript’s text item delimiters to {“:”}

My two cents :wink:

Agreed Xcode can be very touchy. Thank you Joseph, I’ll let you know how I get on.

Try “cellValue of cell .”

Hi mouramartins, tried and failed already. :frowning: Thank you anyway. :slight_smile: