I have a custom setting that I created with some variable, one of which is a number field. In apex, I want to determine the number of digits that the field is allowed. I'm new to the world of custom settings, but can you do this? if it were an sObject, you could use this Class http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm

works on objects:

Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe();

custom settings, not so much:

Schema.DescribeFieldResult F =Cust_Setting__c.field1__c.getDigits() ;

1 Answer 1


Have you tried getScale() and getPrecision() ? They work for me on Custom Setting Numbers.

Schema.DescribeFieldResult F = Cust_Setting__c.field1__c.getDescribe() ;

Precision is the number of digits to the right of the decimal point. Scale is the number of digits in total. So:

Scale - Precision = number of digits to the left of the decimal point

I would have assumed that any Number datatype with 0 decimal places was treated as an integer but apparently not, in the case of Custom Settings at least.

  • Could you mark the answer as correct?
    – Dominic
    Sep 4, 2014 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .