The Quote Number field in SugarCRM is an auto-increment field (the incrementing takes place not in SugarCRM itself, but in the database). It also has an index on the field with a unique
constraint.
Because of this, the field can't be reset simply. The Quote Number must be unique, and it must auto-increment.
In order to have a resettable Quote Number field in SugarCRM, you would need to create a new field with some special logic and/or create a SugarCRM package that customizes the behavior of either the default Quote Number field, or a new but equivalent field, and updates anything else using the Quote Number field in a concatenation function to use the new field.
That would be the best way, though it would require the most work. This is also the best way to accomplish what you need if you are using SugarCRM On Demand, rather than hosting it on your own server. And it is the only upgrade safe way to do this. There may already be a package out there that lets you do this, so you should probably check out SugarExchange.
Alternatively, you'd need to alter the Quotes database table vardefs, remove the unique
constraint on the index quote_num
, then reset the auto increment value of the database table to get it to start counting from whatever number you want.
To make this, albeit unrecommended (as it breaks compatibility with future SugarCRM updates and may have unintended side effects for anything that relies on this specific behavior of the Quote Number field), modification, follow the below steps.
This assumes you are hosting your instance of SugarCRM on your own server and not on SugarCRM On Demand, and that you are using MySQL. There are also several different ways of ultimately making the Quote Number resettable; this is just one of them - it may not be the best.
Make a backup of your database and your SugarCRM instance. You should be doing these backups regularly no matter what, of course.
Edit {SugarCRM root}/modules/Quotes/vardefs.php
to remove the unique
constraint on the quote_num
index. You can find this in the indices
element of the $dictionary['Quote']
array, toward the bottom of the file.
Before:
array('name' =>'quote_num', 'type'=>'unique', 'fields'=>array('quote_num', 'system_id'))
After:
array('name' =>'quote_num', 'type'=>'index', 'fields'=>array('quote_num', 'system_id'))
Execute a Quick Repair and Rebuild. You do this by going to the SugarCRM Admin page, clicking on Repair, then Quick Repair and Rebuild. Once the first pass is over, you will see a text box at the bottom of the page with an SQL statement or two in it. Clicking on the "Execute" button will apply the updates you made to the Quotes vardefs index entry.
Reset the quotes
table's auto increment value. If your database is MySQL, you can do this by executing: ALTER TABLE quotes AUTO_INCREMENT=1
(if you want to start counting at 1 going forward).
Once those steps are complete, your Quote numbers will then start from 1 again (or whatever number you specified in your ALTER TABLE
statement), and you will be able to reset the number again in the future by re-executing the ALTER TABLE
statement.