When setting a serial ID, the "On record commit" setting doesn't stop the record from being committed. All it does is control the timing of when the serial ID is assigned. If you set it to "on creation", then the serial ID is assigned when the record is created, prior to the changes being committed back to the database. On the other hand, if you set it to "on record commit", then the serial ID will be assigned when the record is committed. The difference between the two is largely there to prevent a serial ID from being assigned to records which may be reverted prior to first commit.
In order to prevent records from being committed automatically, you can disable the "Save record changes automatically" option in the Layout Setup dialog:
This will cause FileMaker to prompt the user and ask if record changes should be saved.
Ok I have mine that way but how do i do 2 things
1- Get the Next Key value to show in the field or a field
2- Not increment even when there is no record saved?
I did exactly that and here is what I got in return:
I picked new Invoice, and got a clean window nothing in the fields except Date
I even tabed from Invoice ID to CID and keyed in a valid Customer ID
Still no Next avail Key showed up. I used the following:
And told it do not store as shown in your example pic.
How is your "Invoice ID" field defined?
Well from what I can see your Script is:
GetNextSerialValue ( Get ( FileName ) ; "serialID" )
and Mine is :
Is "Invoices" the name of your file?
Does "Invoice ID" live in the current table?
Yes and yes
Hopeing this can help clear up some of the fog around what I am trying to do:
1) I need to be able to show a new Invoice window with the default key showing
Allowing them to hit ENTER or TAB to leave it in play. And then proceeding on to the other
fields to create a new record if need be.
Now on the other hand, If they are there and need to chance the Default value to an previous
existing # to edit a rec they can and when they key it in it looks up the record. (Like find)
Also making sure the system does not save anything unless told to do so by the user.
And a very important factor is Keeping the incremental counter in sync with the next avail highest rec #.
Hope that helped.
What you really need is a global field, set via script, when users enter this screen. You will need to do several things to make the interface you're looking for work in the way you desire:
1) Create a global field (probably Number type) that fits where the invoice ID field fits.
2) When your script goes to that new window, have it automatically insert the next value, using GetNextSerialValue.
3) Insert one or more Script Triggers on the fields on this layout that cause FileMaker to choose what action to take: Perform a Find or create a new record, depending on what the value in the global ID field is equal to. (If it's equal to an old value (i.e., less than the value you set via script), it should perform a Find; otherwise, it should proceed to creating a new record.
4) You'll need to turn off the "Save record changes automatically" option in the Layout Setup to force the user to save changes.
5) You'll need to trap any cases where the user inserts a value other than a previously-entered value OR the next value in line. (Your Script Triggers will need to test the value the user enters to make sure it's valid.)
I might note that, this type of interface has significant potential issues. If you have more than one user attempt to do this at the same time, they will both likely get the same next value (because the next value won't actually be created until one of them commits a new record). In fact, there may be a significant lag between the time the value is shown to the user and the time the record is actually committed; they don't even have to do it close to the same time. I don't know how important it is that your users actually see the invoice value, but I would recommend that you not even worry about letting them see the next value in line. If they want to search for a previously-issued ID, fine, but worrying about what the next value will be is problematic in a multi-user environment, especially in any situation where you allow users time to play with the record prior to committing that value to the database. The value they see may well not be the value they end up getting.
Short version: This isn't multi-user safe. Of course, if you don't have multiple users accessing the system at the same time, then it's not an issue.
Thank you Mike, I will see what I can do to get them to change their mind as it seems there could be a lot of trouble brewing
Perhaps a suitable substitute would be the last number issued? This you could do with a self-joining relationship and a calculation field, avoiding the issue of necessarily having to prepopulate the next number in line. (You could use an OnTimer script trigger to refresh the window on some predetermined frequency to keep the number fresh if there's enough traffic.)
Of course, that does bring up another possibility: You could use a self-joining relationship and a calculation field to display the last number issued, plus one. That would, at least in theory, give you the next number in line. It could be refreshed with a triggered script, and might give you what you need without messing around with GetNextSerialValue.
Something to consider.