Go to Object( "ObjectName" ) Gotcha for New Players

Let me explain. I have an abstracted record deletion script. By that I mean I want it to be able to go to any layout and find a name field an use it to find a record for deletion. This means it can be used to delete records on layouts with different tables. It goes like this;

Go to Layout( "SomeLayout" )

Go to Object( "PrimaryID" )

Enter Find Mode

Set Field ( $PrimaryID )

Perform Find

If found count is 1

Delete Record

End If

This script fails if the found count is 0 to start with. It's not a problem if you do a Show All Records first but it is a gotcha for new players.

The problem is that when the object is a field it seems that as far as FileMaker is concerned the object does not exist unless there is a record. You can have other objects on the layout with a 0 found count and the Go to Object() function will work for them.

So my question is "Is it a bug or a feature?"

Simon Plint


Hi Simon!

This is interesting behavior that you've highlighted.

I went ahead and created a few scripts to test the behavior myself.

A couple things to consider:

1. Field objects are children of records. In order to interact with them, there must be a record present. Whereas other layout objects, are children of layouts.

Just like you cannot go to a related record if one doesn't exist, you cannot go to a field if a record doesn't exist. Does that make sense?

Using the Go to Field will result in the same error when no records are present. (See attached screenshots below.)

2. Regarding the script steps that you've included in your delete script, why are you including Go to Object in the first place? Is there a particular reason?

3. Be wary of universal delete scripts. Each table should have it's own set of rules regarding what records can and cannot be deleted.



Go to Field Script:

Go to Object Script:

Kevin Kurpe


Thanks for your reply.

The reason I use goto object is that it abstracts from the need to state a specific field name in a find request. I use data separation and I want to have a single record deletion script in the data file. All my records have a type field and in the data file there is a layout for every record type. This means I can call a single delete script in the data file and pass it a Primary ID and a record type and it will do the rest. In a similar way I can create records as well.



Try entering find mode before using Go To Object. That way, there's already a request with a field for you to go to. Also, you should consider entering Find Mode before going to the other layout as a performance improvement; you won't load any records over the network when you switch layouts that way.

Jeremy Bante

Cool, will do. Thanks Jeremy.

Back to questions