Field with unique and auto-increments values I have a content type that in one of their fields need a value that is unique and auto-increment.
There are several obvious solutions:


Use the node id that is unique and auto-increment. 
The Serial module.


The problem with these solutions is that they use the MySQL auto-increments.

Drupal, by default, auto-increments the node ID (nid) and other IDs by one digit for each piece of content you create. You can see this if you visit your site by the node ID path: 

http://www.example.com/node/1
http://www.example.com/node/2
http://www.example.com/node/3


However, sites that use database replication as a backup strategy (is my case) often will have non-sequential ids, meaning that you could see nids jump by two or more digits. 

http://www.example.com/node/10
http://www.example.com/node/15
http://www.example.com/node/20


The MySQL auto_increment_increment variable determines how many digits to jump for each successive auto_increment value.

And then I have this problem:

How I can do to have a field with unique and auto-increments values?
You can achieve it yourself in your custom form submit, lets suppose your field name is  myfield ( machine name will be field_myfield and it is text) and your content type is news ( change them with your data) 
first in form alter you can hide it ( it you don't want user see it )
Get idea from my code 

function yourmodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if($form_id == 'news_node_form'){
        if($form['nid']['#value']){
          // if we are in adding new node hide that field and add custom submit handler
                hide('field_myfield');
                $form['#submit'][]='_my_autoinrement_submit_handler';
            }
    }
}



function _my_autoinrement_submit_handler($form, &amp;$form_state) {
$lastValue=0;
// search for the last value 
$query= db_select("field_data_field_myfield","mf") -&gt;fields("mf")
 -&gt;condition('bundle', 'news','=')
    -&gt;condition('status', 1)
    -&gt;orderBy('field_myfield_value', 'DESC')
     -&gt;range(0,1);
     $result = $query-&gt;execute()-&gt;fetchAll();
     if($result){
         //get last value entered before this
        $lastValue= current($result)-&gt;field_myfield_value;
     }
     // increment last value ( biggest one )
     $lastValue ++;
   //set it in node
    $form_state['values']["field_myfield"]['und'][0]['value']=$lastValue;

}