Accessing List Custom Setting data
We can access the data using the custom settings methods. They are all instance methods, that is, they are called by and operate on a specific instance of a custom setting.
- To fetch the custom fields associated with a list setting, use
getAll()
method. It returns a map of data set names and custom setting records. - To fetch all the field values associated with the specified dataset, use
getValues()
method. This method can be used for both list and hierarchy settings.
Map students = Student__c.getAll();
CustomSettingApiName var = CustomSettingApiName.getValues(dataset_name);
Eg: Student__c stud = Student__c.getValues('John');