NUMBER_OUTSIDE_VALID_RANGE: <field>: value outside of valid range
You wrote a number to a field that exceeds the field's configured precision/scale or hard-coded limits (e.g., negative on a year field). The error names the field and (usually) the value. The fix is either reshaping the field or clamping the value upstream.
Also seen asNUMBER_OUTSIDE_VALID_RANGE·value outside of valid range·Number out of range salesforce
Number / Currency / Percent fields in Salesforce have configured precision (total digits) and scale (decimal digits). The total digits cap is precision: a Number(10, 2) field accepts up to 8 digits before the decimal + 2 after. Exceed those bounds, you get this error.
Read the field's shape
| Term | Meaning |
|---|---|
| Length / Precision | Total digits, including before-and-after decimal |
| Decimal Places / Scale | Digits after the decimal |
| Maximum value | precision − scale = digits before the decimal point |
A Number(10, 2) field accepts:
- Up to 8 digits before the decimal:
99,999,999.99 - 2 decimals
- Maximum value:
99999999.99
A value of 100,000,000 (9 digits) overflows — you get NUMBER_OUTSIDE_VALID_RANGE.
Fix 1: clamp the value before insert
Decimal raw = computeRevenue();
Decimal max = 99999999.99;
acct.Annual_Revenue__c = raw > max ? max : raw;
Better, log a warning when clamping happens — silent clamping is a bug-discovery problem.
Fix 2: increase the field's precision
Object → Field → Edit → bump Precision and Scale. Note: this is a destructive change in some cases (existing values are not lost, but reports may render differently). Test in a sandbox first.
Maximum precision for Number is 18; for Currency it's also 18; for Percent it's 16. Beyond those, you need to use a different storage shape (separate "millions" + "remainder" fields, or a Long Text Area for arbitrary-precision strings, or move the calculation to a derived field).
Fix 3: use a different field type
If your value can range over many orders of magnitude (e.g., scientific calculations), the platform's number fields aren't ideal. Two options:
- Store as Text and parse on read — keeps full precision but you lose aggregate functions
- Store the log —
log10(value)into a Number field, exponentiate on read
This is unusual; most business values fit comfortably under 18 digits.
When the field is computed
Formula fields can return values outside the field's range. Salesforce silently truncates and shows #Error! in the UI rather than throwing this exception. If you're chasing missing data on a formula field, audit for values that would exceed the field's range.
A common cause: percent arithmetic
A Percent field stored as 0.85 displays as 85%. If your code multiplies before insert:
acct.Discount_Pct__c = 85; // ❌ stores as 8500%, exceeds the 100 cap if there's a validation
Fix: store the natural form. The platform formats for display.
