If I understand you correctly, you are looking for is an integer field that auto-increments for each new record.
I have a custom module called wcont_Contracts which has a Contract Number field that is populated by the system as an auto increment number.
The Contract Number is an Integer, Required, Read-Only field with auto_increment set to true.
In the vardef of my field is as follows:
'required' => true,
'name' => 'contract_number',
'vname' => 'LBL_CONTRACT_NUMBER',
'readonly' => true,
'len' => '11',
'required' => true,
'auto_increment' => true,
'unified_search' => true,
'boost' => '3',
'enabled' => true,
'comment' => 'Visual unique identifier',
'duplicate_merge' => 'disabled',
'disable_num_format' => '1',
'duplicate_on_record_copy' => 'no',
'audited' => false,
'massupdate' => false,
'merge_filter' => 'disabled',
'calculated' => false,
'enable_range_search' => false,
'min' => false,
'max' => false,
Then on the database I altered the field to be an auto-increment and start the numbers from 10000
ALTER TABLE `wcont_contracts`
CHANGE COLUMN `contract_number` `contract_number` INT(11) NOT NULL AUTO_INCREMENT, ADD INDEX `contract_number` (`contract_number`);
alter table wcont_contracts AUTO_INCREMENT = 10000;
You won't see the number in the record until after you Save, but it is created and entered for you.
Hope this helps,
HI, Francesca, I really appreciate you help.
It is not a good approach to previouly display the next booking number because, lets say, two receptionists create records at the very same time! It may through an exception on database once that field can not be duplicated. Actually we faced that twice on different customers years ago!
So you really need to let SugarCRM to auto generate this field as soon as its record is saved into database.
Regarding the issue on your instance, I'm afraid that your custom CreateView has not been properly implemented, which may been leading to a kind of looping.
Francesca Shiekh's suggestion certainly will work, not exactly as you would like to have implemented, but this is the best approach you may find.