sap commerce cloud
How to Reset Order Number Sequence in SAP Commerce Using Groovy Script
During development, testing, or data correction in SAP Commerce Cloud, you may need to reset or update the order number sequence. Instead of changing code or database entries manually, SAP Commerce provides a powerful way to do this using Groovy scripting in hAC. In this article, we’ll walk through how to safely reset order numbers using NumberSeriesManager.
May 1, 2026•2 min read
1. Why Reset Order Number Sequence?
Common scenarios include:
- Testing order placement from a specific number
- Fixing incorrect sequence values
- Aligning with external/legacy systems
- Data cleanup in lower environments
2. What is NumberSeriesManager?
NumberSeriesManager is the internal API used by SAP Commerce to:
- Manage number series
- Store current sequence values
- Reset or update sequences
It works directly with the same data used by PersistentKeyGenerator.
3. Where to Run Groovy Script?
You can execute Groovy scripts from:
👉 hAC (Hybris Administration Console)
- Go to: Console → Scripting Languages
- Select: Groovy
4. Basic Groovy Script to Reset Order Number
Here’s a working example:
import de.hybris.platform.jalo.numberseries.NumberSeriesManager;
NumberSeriesManager numberSeriesManager = NumberSeriesManager.getInstance()
def orderNumberKey = "order_code"
def numberSeries = numberSeriesManager.getNumberSeries(orderNumberKey)
println "Old Value: " + numberSeries.currentNumber
numberSeriesManager.resetNumberSeries(orderNumberKey, "120000000099", numberSeries.type, numberSeries.template)
numberSeries = numberSeriesManager.getNumberSeries(orderNumberKey)
println "New Value: " + numberSeries.currentNumber5. Script Explanation
- getNumberSeries() → Fetch current sequence
- currentNumber → Current order number
- resetNumberSeries() → Updates sequence value
Parameters:
- Key (
order_code) - New start value
- Type (numeric/alphanumeric)
- Template (optional)
6. Example Output
Old Value: 00000045
New Value: 120000000099Next order placed will continue from:
1200000001007. Important Notes
- This directly affects future order numbers
- Existing orders remain unchanged
- Works instantly (no restart required)
8. Common Mistakes
❌ Using wrong key
→ Ensure it matches your generator (order_code, us_order_code, etc.)
❌ Running in production without validation
→ Can break order sequencing
❌ Incorrect format
→ Must match configured type (numeric/alphanumeric)
9. Best Practices
- Use only in dev or staging environments
- Take DB backup before running in production
- Validate key name before execution
- Log old values before resetting
10. Advanced Use Case
For multi-site setup:
numberSeriesManager.resetNumberSeries("us_order_code", "U000000000100", "alphanumeric", null)
numberSeriesManager.resetNumberSeries("in_order_code", "I000000000500", "alphanumeric", null)Conclusion
Groovy scripting in SAP Commerce Cloud is a powerful tool that allows you to modify system behavior without code deployment. Resetting order number sequences using NumberSeriesManager is quick, efficient, and extremely useful for developers and testers.
What’s Next?
👉 You can now explore:
- Debugging order code issues
- Advanced key generator customization
- Production-safe scripting practices