# Managing Document Numbering

Many companies have complex requirements around document numbering. For example:

  * All SOP are numbered _SOP-XXX_, where _XXX_ is an incrementing number.
  * Promotional Piece documents use _PP-{Product\_Abbreviation}-XXX_, except the Web asset subtype, which will use _WEB-{Product\_Abbreviation}-XXX._
  * All documents use _VEEVA-XXX._

Vault's auto-numbering functionality supports these different scenarios.

## Access Document Numbering Options

You can manage document numbers from **Admin > Configuration > Document Types**. To do this, you must have a security profile that grants the **Document Types**: **Create** or **Edit** permissions.

### Access Document Auto-Numbering Configuration {#access-document-numbering-options}

You can export a CSV file containing active document auto-number formats and their last used values by navigating to **Admin > Configuration > Document Auto Number** and clicking **Export**. You can also update document auto-numbering by clicking **Import** and selecting a CSV file with document auto-numbers and last used values. The imported CSV file can contain up to 100 rows. 

## How to Set the Base Numbering Format

New Vaults use a temporary numbering scheme that applies at the base document level. To change the base numbering scheme:

  1. From the **Document Types** page, choose **Edit Details** from the **Actions** menu for _Base Document_.
  2. In the **Document Number Format** field, enter the numbering scheme. If needed, click the token icon to search for and insert tokens. The token for an auto-generated, incrementing number is _{###}_ with a number symbol for each digit.
  3. Click **Save**.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: Auto-generated numbers and their resulting document numbers may not be unique.</p>
    </div>
  </div>
</div>



## How to Override the Base Numbering Format

All document types inherit their number format from the document type above them (subtype from type, classification from subtype, etc.) unless you define a different format specifically for that type, subtype, or classification.

To override the base document number format:

  1. From the **Document Types** page, navigate to the document type, subtype, or classification to change and choose **Edit Details** from the **Actions** menu.
  2. The **Document Number Format** field automatically shows the inherited format or any existing override format. Enter the new numbering scheme. If needed, click the token icon to search for and insert tokens. The token for an auto-generated, incrementing number is _{####}_ with a number symbol for each digit.
  3. Click **Save**.

After changing the document number format, you may wish to start document numbering at a number other than the default. To do so, navigate to **Admin > Configuration > Document Auto Number** and [import a CSV][1] with the new starting document number as the _Last Used Value_. The new starting value cannot be lower than the existing _Last Used Value_.


## Tokens

Numbering formats support tokens for the following:

  * Autonumber, _{####}_: Auto-generated, incrementing number; each number symbol represents a digit in the generated number. In many cases, this number will include leading zeros (0001, 02984, etc.).
  * Object Fields, _{field\_name}_: Document's values for the object field; Vault provides tokens for fields of the following types: _Name_ (standard field), _Status_ (standard field), _Text_, _Number_, _Picklist_. These are available for standard and custom objects. If a document has multiple picklist options selected, the generated number uses the first value. See [below][2].
  * Created Month, _{created\_date\_mm}_: Month that the document was created in a two digit format. (February is 02, November is 11, etc.). At the end of each month (March 31, for example), the autonumber token {####} resets. See [below][3].
  * Created Year, _{created\_date\_yyyy}_ or _{created\_date\_yy}_: Year that the document was created, in either 4 or 2 digit format. At the end of each year (December 31), the autonumber token {####} resets. See [below][3].

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: Document auto-numbering does not support metadata that includes <strong>{curly brackets}</strong>. If necessary, we recommend using <strong>(parentheses)</strong> or <strong>[square brackets]</strong> instead.</p>
    </div>
  </div>
</div>



## Multi-Select Fields as Tokens {#first}

When using a multi-select field as a token, the generated number uses the first value of those selected. Use one of the following options if you want to avoid this variability:

  * Avoid using multi-select fields in the document number.
  * If your Vault uses alphabetical sort for selected values, select a single value during document creation and select additional values later. Vault generates the document number once during document creation. After the number is generated, selecting other values for a field used in the document number will not cause it to update.

## Special Rules & Details

  * If you use the same sequence, for example, _SOP-{####}_, in two places, they share the numbering value so that it is impossible to create two documents with exactly the same number.
  * If your organization imports documents <a href="/en/gr/26597/#migration-mode">using the Vault API's Migration Mode</a>
, it is possible to create documents with identical document numbers.
  * If you assign an auto-numbering sequence, and then decide to stop using it, the sequence persists in your Vault until it is used again. So, if you create _SOP-0001_ and _SOP-0002_, stop using the _SOP-{####}_ format for a year, and then turn it back on, the next document will be _SOP-0003_.
  * When Vault reaches the end of the current document numbering sequence (for example, the sequence _SOP-XXXX_ reaches _SOP-9999_) and the next document that uses the sequence is created, Vault automatically expands the sequence to include an additional digit (for example, Vault expands the sequence to _SOP-XXXXX_ and numbers the document _SOP-10000_).
  * Vault warns you about sequences that are close enough that they could be misconstrued as the same, for example, _SOP-{####}_ and _SOP{####}_, but does not prevent you from using these. We do not recommend using very similar formats.
  * Once documents exist for a specific document number format, you cannot change the number of digits in the auto-number token for that format, for example, to add leading zeros. You must make other changes to the format in order to change this.
  * Month numbers repeat every year. If you include the Created Month _{created\_date\_mm}_ token in your document number format without including a Created Year _{created\_date\_yyyy} or {created\_date\_yy}_ token, there may be duplicate document numbers. Vault does not prevent you from using only the Created Month token.
  * <a id="auto_number_reset"></a>When using Created Month _{created\_date\_mm}_ or Created Year _{created\_date\_yyyy}, {created\_date\_yy}_ tokens, the auto-number token _{####}_ resets at the end of each year. For example, you are using the _{created\_date\_mm}-{created\_date\_yyyy}-{####}_ numbering format. When you create a document on December 31, 2016, that document's number is _12-2016-1041_. The first document you create on January 1, 2017 will have the number _01-2017-0001_.
  * If your auto-number pattern uses object reference tokens, updating capitalization of the pattern and referenced object record values, or updating the number of _{#}_ signs only affect future auto-number patterns. To update all existing auto-number patterns, add an additional change to the auto-number pattern configuration other than capitalization or the number of _{#}_ signs.
  * Auto-numbering is not case sensitive. For example, if there is at least one (1) document in the sequence that was already created, then updating the pattern with a case change will not reflect on subsequently created documents. However, if there were no documents created in the sequence, then the updated case change will reflect on the first document that's created.

## Editing Generated Document Numbers

The _Document Number_ field is never directly editable by users. The only situation in which a _Document Number_ value can change is when a user reclassifies the document and the new document type uses a different auto-numbering format.

 [1]: #access-document-numbering-options
 [2]: #first
 [3]: #auto_number_reset
