0

i have a custom setting with a field type "checkbox" set to true but if i try to query it on a class it's allways returning false, i don't know why.

Email_Engine__c ee = Email_Engine__c.getInstance();
    system.debug(ee.Turned_On__c);
    if(ee.Turn_On__c == true){...

enter image description here

  • Do you mind posting how your custom setting is configured? May be a screenshot will help here. – Jayant Das Oct 19 '18 at 15:03
  • 2
    Do you have multiple levels configured (user, profile)? Only the lowest level setting is returned. – sfdcfox Oct 19 '18 at 15:10
-1

You need to have the records created by clicking on 'Manage' button. It will look something similar like this. This is returning the exact value for the corresponding record.

Email_Engine__c ee = Email_Engine__c .getInstance('the record name you want to look for'); system.debug(ee.Turned_On__c);

  • 1
    If he doesn't have any record for this custom setting then this line ee.Turned_On__c should throw null pointer exception. – Pragati Jain Oct 19 '18 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.