You need to sign in to do that
Don't have an account?
Maxine Smith
Help with custom settings
Hi, I'm new to custom settings. I have created one, and can put a query in my developer console window which gives my answer - select Name, NumberOfDays__c from DaysToDelete__c. If I use the very same query in my Apex class, it returns no rows. Why is this? I must be doing something wrong. The custom setting is a list and is public. I know you don't need to use a query with custom settings so I also have a line in my code, DaysToDelete__c myCS1 = DaysToDelete__c.getValues('DayNumber'); This returns nothing too. Please help!
All Answers
1. Custom settings can be accessed into apex using its key values.
Go to custom setting DaysToDelete__c, then click on manage, Click on the data what you want to refer. You will find the name. Make a note of the name and go to apex class and modify the line as below.
DaysToDelete__c myCS1 = DaysToDelete__c.getInstance('name you have choosen');
Let me know if you have any issue in doing this.
Regards
Sampath
Mark this as best answer if this solves your issue.
My code is DaysToDelete__c myCS1 = DaysToDelete__c.getInstance('DayNumber');
When I click Manage under the custom setting, in the Name column is 'DayNumber' so that is what I should be using?