I created a custom setting with two fields Active__c and Age__c. In my apex code, I want to retrieve one record from this custom setting where Name='Days'. This will return only one record. Would I need to use List to get this result or can I simply get this into a variable?

  • How many rows are there in your settings table? Are you interested in having many Age__c and Active__c rows for different "scenarios"? – greenstork Jun 12 '14 at 15:56
  • only one row. I'm not planning on having many rows. – user9862 Jun 12 '14 at 16:03

here you go :

MyCustomSetting__c cs = MyCustomSetting__c.getInstance('Days');
// you then have access to cs.active__c and cs.age__c
| improve this answer | |
  • Thank you very much. This is exactly what I was looking for!!! – user9862 Jun 12 '14 at 16:18

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.