I have a requirement to avoid any compile-time dependency on a managed package. Dynamic SOQL, SObjectType and SObject allow me to do this cleanly for normal objects.
But now I need to access a public hierarchy custom setting from the managed package. With compile-time dependency this would work:
ns__CustomSetting__c setting = ns__CustomSetting__c.getInstance();
But there does not appear to be a dynamic alternative API; methods like
getInstance() are not present on SObject. Or have I missed something?
Is the only approach available to use dynamic SOQL to query the various rows of the hierarchy and emulate the semantics of
getInstance() in Apex code?