Reset Serial module annually I'm a newbie to drupal 7 for a year by now. I'm trying to make a unique id field that would increment per node of content type I create. 

The computed fields module + serial module is the likeliest method accomplishing my goal, yet I'd like to restart the serial number starting each year, I'm totally lost, please help. 

This is the code I've used.
The output: 20150001, 20150002 and so on.
Is there a method to restart the serial num. back to 0001 again when it's a new year?


Computed Code (PHP)

$entity_field[0]['value'] = $entity-&gt;field_serial[LANGUAGE_NONE][0]['value'];

Display Code (PHP)

$display_output = date('Y') . sprintf('%04s', substr(str_pad($entity_field_item['value'], 4, '0', STR_PAD_LEFT), -4, 4));



This is another method I've found, it works on the D6 website, but turns into a blank on my D7 published contents. It's from a field on D6 using php filter module.

&lt;?php
$case_id_query=db_result(db_query("select  max(field_case_id_value) as id  from {content_field_case_id} "));

$case_id = date("Y") . sprintf ( '%04s', substr ( $case_id_query, 4, strlen ( $case_id_query ) - 4 ) + 1 );
return array(
  0 =&gt; array('value' =&gt;$case_id),
); 
?&gt;


can I transform the method above to D7?
I recommend in the future to peruse the Module issue queue. :)

There are a number of patches in the following issue thread, one of which I've used to reset yearly (and actually modified to reset monthly): https://www.drupal.org/node/2168071