The icons in the toolbar are tied to menu commands. In your example, the New Record button is tied to the New Record menu item. You can commandeer these commands using Custom Menus and substitute a script of your choosing instead of the default command.
Thank you Mike, I found the debugger in FileMaker and stepped through the code in the sample and found that they are hooking in to the event for creating a new record with the standard menu item. When the new record event fires there is a script that takes them to the newly created record in the detail layout immediately.
You can specify triggers connected not only to a field or object, but also to a layout.
In layout mode select Layout Setup... from the Layouts menu, then go to the "Script Triggers" tab and you will find the trigger you are looking for ( OnRecordLoad)
What happens is:
- The list layout has a script attached to the OnRecordLoad event;
- Creating a new record while being on that layout, either by using "new record" from the Records menu or by using the icon in the toolbar or by using a button created by you, will trigger the OnRecordLoad, because a new record gets "loaded".
Just to build on siplus's answer:
There is no "new record" event in FileMaker. You can find a complete list of Script Trigger events here:
It's worth noting that the OnRecordLoad event will fire every time a record loads, not just a new one. So browsing through records, entering Browse mode with a non-null found set, switching layouts to the layout on which that trigger is set, etc., will all cause that trigger to fire.