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
Kenji776Kenji776 

Change autonumber to text and back again.

Hello all.
We have an autonumber field called CID__c, sometimes we need to modify one of them. So I need a way to change the field type from autonumber to text so it is editable, then change it back to autonumber. Can you change a field type through the API?
Also, what would the query look like to select the largest CID out of Account object and assign it to a variable, so when I have to change it back to autonumber I have a number for it to start counting at. Thanks!
werewolfwerewolf
I don't think you can do that, and almost definitely not through the API.  If I were you I'd make another field, a text field, called something like CID Override.  You can put your override in there.  Then make a formula field that says IF(ISNOTNULL({!CID_Override__c}),{!CID_Override__c},{!CID__c}), so that it'll show the override if there is one, otherwise it'll show the autonumber.