Once I had the illusion that accessing custom setting is always free and does not consume any governor limits. Until today: I've learned the hard way that this is only half-true.
It is true, that this comes without the cost of a query:
MyCustomSetting__c.getall().values();
But this DOES cost you a query
database.query('select Id from MyCustomSetting__c ');
Now how can I get the setting dynamically in a way that my code runs on every org regardless of the existence of MyCustomSetting__c
? I need to hide the setting from Salesforce so that I can use something inside of a try/catch. If the setting does exist I need to get some values. If it does not exist I fall back on default values.
Can this be done free of charge of any query limit?