Document Naming Rule
Document Naming Rule allows you to generate document names dynamically based on conditions. Unlike Document Naming Settings, which apply a naming series globally to a DocType, Document Naming Rules apply different naming patterns depending on field values within the document.
This provides greater flexibility for organizations that require multiple naming conventions within the same DocType.
Document Naming Rule vs Document Naming Settings
Document Naming Settings apply a single naming series to every document of a particular DocType.
Document Naming Rule introduces conditional logic, allowing different naming series to be assigned automatically based on document field values.
Customer documents can be assigned different naming series based on Country, Territory, Branch, or any other field.
How to Create a Document Naming Rule
1. Select the Document Type
Select the DocType for which the naming rule should be applied, such as Customer, Sales Invoice, or Purchase Invoice.
2. Set Priority
Assign a priority to the rule.
- Rules with higher priority values are evaluated before lower-priority rules.
- If multiple rules satisfy the conditions, the rule with the highest priority is applied.
3. Add Rule Conditions
Add one or more conditions that determine when the naming rule should be applied.
The rule is executed only when all specified conditions are satisfied.
Example
Suppose you want Customer names to vary based on the customer’s country.
- Rule 1
Prefix:CUST-INDIA-
Condition: Country = India - Rule 2
Prefix:CUST-USA-
Condition: Country = USA
Documents would then be generated as:
CUST-INDIA-00001 CUST-INDIA-00002 CUST-USA-00001 CUST-USA-00002
4. Define the Prefix
Under the Naming section, enter the prefix that should be used when the rule is triggered.
Example:
PSI/
5. Set the Starting Serial Number
Specify the starting sequence number for the naming series.
For example:
Prefix : PSI/ Start Number : 5
The first generated document will be:
PSI/00005
Benefits
- Automatically generates document names based on document fields.
- Eliminates manual naming series selection.
- Reduces naming errors and improves consistency.
- Supports multiple naming conventions within the same DocType.
- Ideal for organizations operating across multiple branches, countries, or business categories.
Notes
- Ensure rule conditions are specific enough to prevent conflicts between multiple rules.
- If no Document Naming Rule matches, ERPNext automatically uses the default Naming Series configured in Document Naming Settings.