This module provides an auto-increment (serial) field.

Unlike Drupal's built-in auto-increment node ID, which is global and shared by nodes belonging to all content types, serial fields are managed per content type (D6) / entity (D7). For example, the serial field of an Invoice instance will generate a unique sequential number (starting at 1, then 2, etc.) exclusively for Invoice instances.

The allocation of serial numbers by this module is atomic. In other words, the serial values are unique even when multiple instances of the same content type / entity are created simultaneously.

Dependencies

  • Drupal 6 - the CCK module
  • Drupal 7 - the core Field module has to be enabled

Optional modules

Note: Currently field tokens are not yet supported by Drupal 7. See #691078: Field tokens for details.

Installation

  1. Copy the serial module directory to your Drupal sites/all/modules/ directory.
  2. Enable the module in administer > modules (admin/build/modules).

Usage

You can add a serial field to any type at admin/content/types -> manage fields.
In the New Field form select Serial as the type of data and label and field name as your choice, and Save. No other settings.

Notes:

  • Existing nodes will also get serial values when a serial field is added.
  • Please do not open more issues about integration with Field Collection. This is caused by the lack of proper entity support. See #1333032: Add generic entity support for details. This is a rather large job so any patches would be appreciated.
  • The serial token [{field-name}-id] can be used with Path Auto,
    where {field-name} is the serial field name (e.g. [field_serial-id] for field_serial).
  • If you're upgrading from Drupal 6, make sure that this module is enabled before the CCK to fields migration. You'll get one or more errors about trying to create tables that already exist, but you can safely ignore these. Feel free to create an issue & patch to fix that.

Similar Modules

Serial numbers can be generated also by the Type-local nids module. The main differences between the two modules are:

  1. The Serial Field module provides a CCK field.
  2. ID allocation by Serial Field is atomic (i.e. the same ID cannot be issued to more than one node).

Project Information

Downloads