This is the error I'm getting.

System.DmlException: Insert failed. First exception on row 0; first error: NUMBER_OUTSIDE_VALID_RANGE, DC_geocode: value outside of valid range on numeric field: -117.3411: [DC_geocode__c]

The background on this is that I'm passing in two Decimal values(by necessity) to a method, then I try to set the latitude and longitude of a custom Geolocation field by using those two Decimal values and converting them to double values by doing the following.

DC_geocode__latitude__s = decimalvalue1.doubleValue(); DC_geocode__longitude__s = decimalvalue2.doubleValue();

I've set my custom Geolocation field to use these types of values(instead of degrees and minutes) with a precision of 15 decimal places.

Any help you could give me on trying to figure out why this error may be occurring in this instance would be great!

  • Can you write out the values of decimalvalue1.doubleValue() and decimalvalue2.doubleValue() to the debug log to check what values you are trying to set. – Mark Keats May 18 '15 at 12:48
  • @MarkKeats here is the debug 07:58:46.984 (14984211718)|VARIABLE_SCOPE_BEGIN|[23]|latitude|Decimal|false|false 07:58:46.984 (14984220731)|VARIABLE_ASSIGNMENT|[23]|latitude|-117.3411 07:58:46.984 (14984225253)|VARIABLE_SCOPE_BEGIN|[23]|longitude|Decimal|false|false 07:58:46.984 (14984231246)|VARIABLE_ASSIGNMENT|[23]|longitude|38.1234 – EthanLWillis May 18 '15 at 13:00

You appear to have your latitude and longitude the wrong way around.

  • Latitudes range from -90 to 90
  • Longitudes range from -180 to 180

Your latitude is -117, so outside the valid range.

|improve this answer|||||
  • Wow, you're right. Guess I need to take a break! – EthanLWillis May 18 '15 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.