Often when we need a serial field, it's because we are numbering series of items, documents... and what happens if we need to have some "context" in this numbering schema, like YY/NNNN (YY is two digit year and NNNN is the serial number IN THIS YEAR series)?.

I've managed a quick & dirty solution, tweaking this module, and tested for mysql: I've...

  1. changed from int to varchar in field schema (field value column type).
  2. added a year column in aux table schema.
  3. set primary key as (year, sid) in aux table schema.

All the magic for sid computing is done by mysql, getting correct id in each year serie. (http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html)

It would be nice to integrate this behaviour as optional in this module, in a more elegant way via module configuration menu. Current behaviour (no year series) can be archieved setting year = NULL or some fixed value.

Comments

Anonymous’s picture

This would be a very nice feature to have. Subscribing.

Although...in our case, we have a field for the document year, and this is not neccessarily the current year.
E.g. a few days after the new year, we are still processing nodes marked with the previous year (this is set in a cck date field) that should still be using the old sequence, while also processing new documents, marked with the new year and using a new sequence.

colan’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Status: Active » Postponed

Please provide a patch. Without one, this isn't a priority right now.

As an aside, it'll probably be trickier to get this working with all database types using D7's new DB abstration layer.

colan’s picture

Issue summary: View changes
Status: Postponed » Closed (duplicate)

This one's older, but there's already some work in the other issue: #2168071: Add support for year prefix.