Reference > Script steps reference > Fields script steps > Set Next Serial Value
 

Set Next Serial Value

Resets the next serial value in an auto-entry serial number field.

See also 

Options 

Specify target field specifies the serial number field on which the script step will operate. The field you specify must be defined as an auto-entry serial number field.

Calculated result allows you to enter the next serial value or create a calculation to determine the next serial value.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

Yes 

FileMaker Server 

Yes 

FileMaker Cloud products 

Yes 

FileMaker Data API 

Yes 

Custom Web Publishing 

Yes 

Runtime solution 

Yes 

Originated in 

FileMaker Pro 6.0 or earlier

Description 

You can define this script step to use any calculation expression to determine the next serial value of a field that has been defined as an auto-entry serial number field. The calculation always evaluates to a text result.

For example, you might want to reset the next serial value after you do one of the following:

import records into a FileMaker Pro Advanced database with an auto-entry serial number field

delete multiple serialized numbers from a FileMaker Pro Advanced database

Notes 

This script step affects the definition of the field you specify instead of the actual contents of the field that you specify.

This script step can operate on multiple files. If you specify a field in another file, then FileMaker Pro Advanced attempts to update the serial number for the specified field in the other file. To specify a field in another file, define a relationship to that file and use Specify target field to select a field from that file.

Example 1 

Calculates the number of the next available invoice ID, using the Max function to return the highest value in the Invoice ID field. If an 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 [Invoices::Invoice ID; Max ( Invoices::Invoice ID ) + 1]

Example 2 

Sets the next serial number value in the Product ID field options after importing records. Useful if Perform auto-enter options during import is not selected in order to preserve dates and other auto-entered values.

Import Records [ With dialog: Off ; Table: Products ; Source: New Product Catalog.xlsx ; Worksheet: "Stock" ; Add ; Mac Roman ]
Set Next Serial Value [ Products::Product ID ; Get ( TotalRecordCount ) + 1 ]

Example 3 

Prompts the user to input the next serial value.

Show Custom Dialog ["Set the next serial number value"; Invoices::Next Serial Value]
If [Get ( LastMessageChoice ) = 1]
Set Next Serial Value [Invoices::Invoice ID; Invoices::Next Serial Value]
End If

Related topics 

Import Records script step

Defining calculation fields

Script steps reference (alphabetical list)

Script steps reference (category list)