Elaine Jones Posted November 14, 2007 Posted November 14, 2007 Here's what I'm attempting: In an upgrade script that imports the user's data from a previous version, I can't figure out how to change the next serial number in the Define menu to the serial number of the last record imported plus 1, so that the next new record the user makes has the right number. Can anyone give me some ideas? Thanks a million.
Vaughan Posted November 14, 2007 Posted November 14, 2007 Use the "Set Next Serial Value" script step.
IdealData Posted November 14, 2007 Posted November 14, 2007 Just a little point... The Set Next Serial Value only works on the NUMERIC part of the field... 123 might become 25, however ABC123 would also become 25
comment Posted November 14, 2007 Posted November 14, 2007 I don't think so. I don't see why "123" should become "25", and you can certainly set next serial value to "ABC123" and have the subsequent new records receive the values of ""ABC123", "ABC124" etc. (though it's best for the serial field to be Text in such case).
IdealData Posted November 15, 2007 Posted November 15, 2007 Sorry, the "might" become 25 was purely a (bad) example, however I am correct about the non-numeric part of a serial number, see this extract from the on-line help. I also have experienced this too. The following example calculates the number of the next available invoice ID. If the invoice ID contains non-numeric data, then the calculation would need to be more sophisticated to maintain the numeric and non-numeric data. Go to Record/Request/Page [Last] Set Next Serial Value [Table1::Invoice ID; Table1::InvoiceID + 1]
comment Posted November 15, 2007 Posted November 15, 2007 I am afraid you are confusing two separate issues: Set Next Serial Value [ Table::SerialID ; "ABC123" ] will work perfectly, and the next two records will be issued SerialIDs "ABC123" and "ABC124", respectively. However, the following will not work very well: Set Next Serial Value [ Table::SerialID ; "ABC122" + 1 ] Here the next two records will receive values of "123" and "124". But the reason for this has nothing to do with the Set Next Serial Value[] script step. It fails because the calculation is required to perform a numeric operation on a text value, therefore it needs to convert it to a number first. The correct way to do this is: Set Next Serial Value [ Table::SerialID ; SerialIncrement ( "ABC122" ; 1 ) ]
Elaine Jones Posted November 15, 2007 Author Posted November 15, 2007 Thanks everyone for replies to my question. As it happened, I was creating the correct script step, but because I'd tried so many wrong things first, I didn't see that it worked right because of performing an inadequate test. Just knowing that the steps were right led me to see my problem. Now, my next question: How do I make this function discretionary, so that if there are no imported records the serial number is not reset? Thanks again.
bcooney Posted November 15, 2007 Posted November 15, 2007 Well, who cares? If there were no imported records, the next value in the table is set to 1. That's acceptable. But you could add: If get (foundcount)>0 setnextserial endif That'll skip the setnextserial on a table with no records.
Elaine Jones Posted November 15, 2007 Author Posted November 15, 2007 As it happens, I'm using serial numbers in different tables to "mean" something in various other tables that perform different functions with the data records numbered in certain ranges. If the field were to be set to "1" it would be wrong. Thanks again for quick response.
Elaine Jones Posted November 15, 2007 Author Posted November 15, 2007 Tried the get (found count), but FM7 doesn't have that option. Is there a workaround? Again, thanx. EFJ
Lee Smith Posted November 15, 2007 Posted November 15, 2007 Is your Skill Level Correct? The Get (FoundCount), [color:gray]which was Status (FoundCount) in earlier versions, and can be located in the List of Function. Click on the "All Functions by name" [color:blue]tab, and you see the Get Functions listed about 3/4 of the way down. [color:blue]Highlight Get Functions, and a whole bunch of Get functions will appear, including the Found Count. HTH Lee
bcooney Posted November 15, 2007 Posted November 15, 2007 Yikes! Serial numbers shouldn't mean anything.
Elaine Jones Posted November 15, 2007 Author Posted November 15, 2007 Lee, you're right to wonder about my skill level. I am really quite a beginner at functions I've never found a need for, since I haven't read an entire FileMaker Manual since FM4 (when I was last trained); only learned FM7 on the fly. Thank you for your kind help, Elaine
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now