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...
- changed from int to varchar in field schema (field value column type).
- added a year column in aux table schema.
- 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
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedThis 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.
Comment #2
colanPlease 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.
Comment #3
colanThis one's older, but there's already some work in the other issue: #2168071: Add support for year prefix.