Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Are GetInstance and GetValues methods of custom setting same? According to the documentation here http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm both seem to be same. What you guys think?

share|improve this question
here's some good commentary from Rich Unger, former PMTS @ Salesforce.com - Rich's Rule of Thumb When Working With Custom Settings: Use getValues() when you’re writing custom settings, and use getInstance() when reading them. –  bigassforce Feb 24 '13 at 20:56

1 Answer 1

up vote 2 down vote accepted

You are right both return same Object. I personally prefer the getInstance() method as it makes more sense to me. You access a record by using the value in the Name column (you cannot use the ID or other columns).

 Foundation_Countries__c myCS1 = Foundation_Countries__c.getValues('United States');
 String myCCVal = myCS1.Country_code__c;
 Foundation_Countries__c myCS2 = Foundation_Countries__c.getInstance('United States');
 String myCCInst = myCS2.Country_code__c;
 system.assertEquals(myCCinst, myCCVal);

The above confirms that both return same .

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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