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
Greg GellerGreg Geller 

custom settings call to getAll returns null

Hi all,
I'm new to SalesForce. I created my developer account. I created a custom setting of type list with two fields. I went into Manage tab and entered the data.

When I run a SOQL query, I see the data. When I call myCustomSetting__c.getAll(), it returns an empty Map. Why does the data show up in one scenario and not the other.

Thank you everyone for your help,

Greg
Greg GellerGreg Geller
This is my apex controller class
public with sharing class ComplianceSeqController {
    
    public List<SelectOption> getComplianceSeqs() {
        List<SelectOption> options = new List<SelectOption>();
        System.debug('In getComplianceSeq');
        
        Map<String, Compliance_Seq_test__c> allComplianceSeqs = Compliance_Seq_Values__c.getAll();
	
	// This debug message show that the size of allComplianceSeqs is 0'
       	System.debug('allComplianceSeqs size = ' = allComplianceSeqs.size());

	// We never make it into the for loop
        for(Compliance_Seq_test__c seqValue : allComplianceSeqs.values()) {
            System.debug(seqValue.Name);
        }
        return options;
    }
}

This is my test class
@isTest(SeeAllData=true)
public class ComplianceSeqTest {
   @istest
    public static void TestComplianceSeqFunction() {
        ComplianceSeqController seqValue = new ComplianceSeqController();
        Test.StartTest();
        seqValue.getComplianceSeqs();
        Test.StopTest();
    
    }	
}

 
Greg GellerGreg Geller
Never mind. I was using the test class as the type instead of the custom settings for my retrieval.