Name documents with a Document Naming Rule ​

A Document Naming Rule names documents based on their field values. For example:

  • Customers in India get IDs such as CUST-INDIA-00001.
  • Customers in the USA get IDs such as CUST-USA-00001.

A naming series applies to all documents of a DocType, or the user picks it. A Document Naming Rule picks the prefix by conditions, so users cannot pick the wrong one.

Prerequisites ​

  • The System Manager role.

Create a rule ​

  1. Open the Document Naming Rule list, and select New.
  2. In Document Type, select the DocType, for example Customer.
  3. Enter the Prefix, for example CUST-INDIA-.
  4. In Digits, enter the number of digits, for example 5.
  5. Optional: in Counter, enter the last number used. For example, enter 4 to start at CUST-INDIA-00005.
  6. In Priority, enter a number. When many rules match, ERPNext uses the rule with the highest priority.
  7. In the Conditions table, add the conditions. Each row has a Field, a Condition (=, !=, >, <, >=, <=), and a Value. For example, Country = India. The rule applies only when all conditions are true.
  8. Select Save.

Create a second rule for the USA with the prefix CUST-USA- and the condition Country = United States.

If no rule matches a document, ERPNext names it the usual way, for example with the default naming series.

TIP

Make the conditions of different rules exclusive, so that one document cannot match two rules with the same priority.