+ Start a Discussion

Changing AutoNumber Fields



In my salesforce instance I've added a field to give auto-numbering to contact records. due to a legal requirement. when a contact is inactive I must close the record, when he returns I must re-open the record. Legally I must assign them a new record number, and different number then the one used previously. 


I am wondering how I could change an autonumber field in code, and how I can give new numbers without these being re-assigned to another record later.


One idea is to create a new contact record, take the autonumber from it, and then delete this record.


Can you see a more elegant solution?





Two options I can think of:


1. You could clone the contact when it's reactivated and insert the new contact. A new number will be created automatically.

2. Otherwise you might have to use a custom object/custom setting to maintain the number and increment it everytime a record is created/re-activated.  


"Clone" might be easier than the other option.


The problem with solution #1 is that cloning is that there are some things in the database that point to the object either by way of master-detail relationship (where contact is master) or by way of lookup.


Solution 2 may be workable. I hadn't thought of that. thanks.