2

Autonumber field increments when test class runs and note that in Spring14 salesforce has released an option not to increment when test class runs.

Develop | Apex Test Execution | Options..., selecting Independent Auto-Number Sequence allows one to mostly avoid the gaps in auto-number fields when running tests

But I forgot to check the option and now there is gap in auto number field in existing records. If its a custom field I would have followed the steps from knowledge article but it is Standard Order Number field on Order Object where I don't see an option to Change Field Type to Text when I click on Edit next to Order Number

Below is the screenshot I see when I click on Edit next to Order Number.

enter image description here

2
  • From what you've posted, I don't see where this doesn't apply to standard objects or fields. So what have you tried that didn't work?
    – crmprogdev
    May 22, 2015 at 2:53
  • @crmprogdev I don't see an option to change the field type to text when I click on Edit next to OrderNumber field
    – sfdc
    May 22, 2015 at 3:16

2 Answers 2

1

From salesforce help link

Modifying Standard Auto-Number Fields

The unique identifiers for solutions, cases, and contracts are standard auto-number fields. Each record is assigned a unique number with a specified format upon creation. You can modify the format and numbering for these auto-number fields.

  1. From Setup, click Customize, select the appropriate tab link, and then click the Fields link.

  2. Click Edit next to the name of the field in the Standard Fields list.

  3. Enter a Display Format to control such formatting details as the minimum number of leading zeros as well as any prefix or suffix for the number. See Custom Field Attributes. Format changes do not affect existing records; they are applied only to new records.

  4. Enter the number to be assigned to the next record that is created after you save your changes.
  5. Click Save.
0

Try clicking on "What is This" and you'll see all the formatting options.

Depending on your needs, you may want to try changing your format to something like {YY0000} to reset the numbering to start with the last 2 digits of the year and then up to 4 digits. Also reset the starting number if you wish. You could also use {MM}{YYYY}-{0000} or any variation you desire. The latter, using today's date (my time zone) would get you 052015-0001.

4
  • If you modify the Display Format of an existing field, only records created after the change will be affected.
    – sfdc
    May 22, 2015 at 3:40
  • That's correct. The same applies to the solution you quoted in your post above.
    – crmprogdev
    May 22, 2015 at 3:54
  • But I want to change the sequence numbers to existing records as well
    – sfdc
    May 22, 2015 at 3:56
  • You didn't state that in your original post. You'd need to do that for ALL of your existing records and would likely need to file a case with SF in order to make it happen as it's a READ ONLY field.
    – crmprogdev
    May 22, 2015 at 4:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .