function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shubham Sinha 43Shubham Sinha 43 

How to query on Hierarchical custom setting records in apex

I have a hierarchical custom  setting called Audience__C and i have a checkbox field 'Booking__c'. now i have a requirement if booking__c is checked then update a field. So, how to query and put if condition on custom setting.We are using "Default Organization Level Value".

Please help on this.
OFröhlichOFröhlich
Hi,
don't query the custom setting. Use

audience__c a Audience__c.getInstance() ;
System.debug(a.booking__c);


https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm

If this helps, please mark as Best Answer to help others too.
Shubham Sinha 43Shubham Sinha 43
Hi 
thank you for your reply but how to put if condition ?

        Audience__C highVol = Audience__C.getOrgDefaults();
 
OFröhlichOFröhlich
Hi,
sorry, I don't understand your remark.