Go to Layout [your layout for new records]
Go to Layout [original layout]
Will create a new record in the table referenced in Layout setup | Show Records from for the layout specified in your script. The Freeze Window and Go to layout [original layout ] steps keep this process from being visible to the user. If you want the user to be taken to the specified layout and left there, omit the last script step.
You can prevent a user from creating new records on a given layout if you have Filemaker Advanced. With advanced, you can set up a custom menu that does not include the new record menu option. This disables the choice from the menu and also prevents the keyboard shortcut for new record to work.
And this script should work from wherever the user is in the database, no matter which layout they are currently on when they hit the "New Record" button?
So far, this isn't working for me. I'm not sure I understand where to "apply" the script?
Yes, it should work when the button is placed on any layout on your layout. But perhaps there's a misunderstanding on how new Record/Request works from within a script.
If your layout refers to a table occurrence of the "contacts" table in layout setup, "show records from", then a script that switches to this layout and performs the New Record/Request step while in browse mode, will create a new record in the contacts table. It cannot create a new record in any other table in your database. To create records in a different table, your script would have to switch to a different layout that is based on that table instead of contacts.
The new records created by this script will have all fields empty except for any fields set to auto-enter data such as a creation date or a serial number. If this record needs to be linked via a relationship to other records in your table, you'd need to add additional steps to your script.
I'm working with only one table for this database. Above, you say:
> Yes, it should work when the button is placed on any layout on your layout...
How do I place the "New Record" button on a layout? I always see it in the "header" of the Filemaker interface. I've attached the icon I'm referring to:
That's not a button it's a tool bar icon.
I'm guessing that you want "new record" to always take the user to a layout designed for filling in all the basic fields for a newly created record.
Enter layout mode.
Click the button tool in the status area.
Drag to draw a rectangle where you want the button.
When you release the mouse button, button setup appears and you can select specify script to specify that the script I suggested be performed when the button is clicked. You can now copy and paste this button onto any layout in the file.
If you have Filemaker advanced, you can also create a custom menu where selecting new record from the records menu, clicking new record in the tool bar or pressing the equivalent keyboard shortcut runs the script I posted earlier instead of just doing a new record action on the current layout.
Yes, I'm familiar with creating buttons on layouts. But, apparently, I can't modify the Tool Bar Icons unless I have Pro Advanced?
If I develop and design in FileMaker 11 Pro Advanced, will my clients with FileMaker 10 Pro be able to use the database wihout problems?
custom menus and custom functions created and installed in FileMaker files work just fine when opened in FileMaker Pro, they just can't be modified with Pro--that takes Advanced.
But a simple option is to use a script to hide and lock the tool bar. This frees up more space in your window and you can add buttons and other controls to your layout to take the place of the stuff in the status area for the most part and take up much less space while doing so.
It's also possible to use the OnRecordLoad script trigger to detect the New Record action and switch you to the new record layout.
The OnRecordLoad script trigger sounds like the right approach, since I want to keep all the other functions in the Tool Bar Header. Can you give me some guidance about how to set that up?
It may not work for every database design, but here goes:
1) Define an auto-entered serial number field in your table if you do not already have one. I'll call it PrimaryKey in this example. The trick is to identify when the value in this field indicates that a new record was just created.
2) Define a summary field, sMaxKey as the maximum of PrimaryKey
3) Write this script:
#capture the maximum serial number value and store it in $$MaxKey
Show All Records
Set variable [$$MaxKey ; value: YourTable::sMaxKey ]
Open File Options and assign this script to be performed each time the file is opened.
Now write this script:
If [$$MaxKey < Yourtable::PrimaryKey // a new record was just created ]
Set Variable [$$MaxKey ; value: YourTable::PrimaryKey ]
Go To Layout [New record layout]
In order for this to work, you must open layout setup and set the OnRecordLoad script trigger to run this script on each and every user accessible layout that refers to an occurrence of YourTable.