What's the best way to get the Id of the custom setting referenced in MyCustomSetting__c.getInstance()
for a hierarchical custom setting?
I'm trying to update your current instance of a custom setting via apex, but can't seem to get the Id (therefore no update possible) from .getInstance().Id
. What am I missing?
Best Answer
A few things to take into consideration:
If no custom setting for the current user is defined then it returns a new custom setting and the ID will be blank. Otherwise the getInstance() should return the ID:
See Custom Settings Methods:
If you need more detailed answer then you may be better served by posting your code so we can tell if it is a problem with your code or not.