Join Cris Ippolite for an in-depth discussion in this video Creating auto entry fields, part of FileMaker Pro 8.5 Essential Training.
- [Instructor] In addition to being able to define fields and choose the different field types, once a field has been created, you can select that field and then assign different options to it, as well. In order to define the different options, just choose the field that you want to modify and select the Options button, and you'll see the Options for Field dialog pop up. You'll see we've got several different tabs here, the Auto-Enter, Validation, and Storage. We're actually going to look at these three, but first, let's take a look at the Auto-Enter options. What does auto-enter mean? Well, FileMaker Pro allows developers to specify a range of different options for automatically populating the contents of a field.
You can see that we can populate it with the creation/modification date or time. So in this particular case, we'll notice that this is a number field, and if we want to put into the number field every time a new record is created, so basically what auto-enter means is each time a record is created, we're going to populate this field with some data. It could be the creation date, the creation time, or the computer name of the user that was creating this. Remember, when we set up the preferences, the user can change that computer name, and that's what shows up here.
Or the account name of the user that creates the record can appear, if you want. The account name is something that we'll cover in security. But the idea, the difference between the computer name or the account name are that someone could log in on a different computer, and then that way, you'd want to see who that person is rather than what station they actually logged in on. The options for creating a field and modifying a field, that's actually a common developer technique known as housekeeping fields. You can set up housekeeping fields. For example, you see that we've got the creation.account, creation.timestamp, modification.account, and modification.timestamp already set up in this table.
These are a good idea and a good practice, kind of like the kind of fields that you might not think are necessary until maybe you've run into some problem with your data. Then, you want to go in there, and you'll be able to see on a record-by-record basis who created these or who modified the records and possibly narrow down the source of a problem. If we look at the options, you'll see that all we did for this particular housekeeping field is simply say under the creation account, let's enter the account name each time a record is created. Under the modification account, each time a record is modified, which means that it's already been created and somebody goes into the field and changes the data, we want to enter the account name of that individual.
Now, these housekeeping fields, you don't necessarily need to put them on every layout. You can actually store them only in a special layout that maybe only the developer sees. Then, this way, you can search through those and see different times, of course, if you do the timestamp, when records are created or when records are modified, for example, and see who actually made those changes. These particular housekeeping fields are a good idea to create in your FileMaker databases whenever you set them up. So if you use a FileMaker template, you might want to add those. Or if you're just creating a template for yourself, it's probably a good idea to allow those fields to be created each time you set up a new database file.
The next type of option under the Auto-Enter options, you'll see, is the serial number, setting up a serial number. Now, this means that each time a record is created, FileMaker Pro will start this value right here, whatever value you put in, and you see the default value is number 1, and it'll increment it by one number. So if I set up a field as a serial value, let's actually do that. Here we've got a serial value called id, and the starting value or the next value is A0208, and it'll increment by one.
So let's go take a look at how that looks on our layout. If we go into layout mode and drop that id field on this layout. And we save that. We'll see that we have a value of 1102. Now, next time I create a new record, we actually see that the value changed to A0208, and that's actually what we wanted it to do. If we look at the Auto-Enter serial, it is now automatically changed within the definition here to A0209.
So FileMaker Pro automatically stores this value and then increments it for you. Even if you delete this record, if we go in under Records and hit Delete Record, we will see that it'll still increment the serial to the next value. Serial numbers are used to uniquely identify each record in your database, and when we get into the relationship section, you'll see that this is how we set up key fields, which are very critical to being able to create relationships between tables.
The other thing you'll notice here, now the serial number value is not something that's unique to FileMaker Pro 8, but in FileMaker Pro 7, you see you have the option of generating a serial number on creation or on commit. Now, what's new about FileMaker Pro 8 is when you create a record, just like we did here, if I just simply create the record and I haven't yet clicked in any area or hit my enter button, it hasn't yet done what's called committing the record. So before, when you would create a record, it would automatically be saved to your database table, but in the new version of FileMaker Pro, this isn't necessarily the case.
Right now, I haven't clicked on anything, and it serialized this value as A0209. If I go ahead and hit enter or click into any one of these fields, I've now committed the record to the database, which means it's saved. Now, if we go in here, and we'll see how this behavior is a little bit different. If we say that we want to go to the next serial value only on commit, note here the next value, A0210, and we're going to create a new record. Now you notice that value hasn't actually appeared yet, and it'll only appear when I hit this record.
Now what I've done is actually committed it, hitting the enter button. Now, the reason you'd want to choose that option, for example, is on creation, maybe you have a limited number of serial values. These examples are few and far between, but sometimes you might want to match a pre-printed card or pre-printed invoice number, and you don't want to actually just throw away numbers, because it might be more wasteful that you have to throw that document away, for example. If your clients or your users are concerned about saving these numbers and they don't want to have any gaps in that serial sequence, you might want to just say to actually serialize on commit rather than on creation.
That way, if they create a record automatically and then discard it, this value won't be lost. In addition to serial values, we've also got a couple of different options in here. The value from last visited record. This is something not necessarily used all the time, but for example, you might have a database application where you're entering in voter information. Since the voter polls are all in the state of California, you might want it to pull in the value from the state field from the previous record, because otherwise, your user's just going to constantly put the same value into this field.
Not a terribly common type of auto-enter, but something that can be used in particular cases and might be useful. A lot of times you see it is with city and state. If, for example, when I just talked about the voter polls, if every single record in your database, let's say in the state field, is going to have, let's say, more specifically, in country. If you know that every single record that's going to be created in this database ever is going to have the value of USA, then you can actually select the data field and then type in USA.
Now, when a new record is created, you see it automatically puts the value of USA in this field. Now, you can actually change this value by clicking in and assigning another value to it, but this is helpful that prevents users from having to type the same data in over and over again.
- Understanding database concepts
- Using FileMaker Pro template files
- Designing database layouts
- Choosing file options
- Finding and sorting data
- Creating value lists
- Printing basics
- Calculation and scripting essentials
- Defining data relationships
- Database security