function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
beener3beener3 

Changing AutoNumber Fields

Hi.

 

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?

 

Thanks,

Ben

Anand@SAASAnand@SAAS

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.

beener3beener3

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.