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
Nisha Babu 8Nisha Babu 8 

How to take each field of a row in custom setting to process it

apex sfdevapex sfdev
Try the code like this,
 
List<Games__C> mcs = Games__c.getall().values();
boolean textField = null;
if (mcs[0].GameType__c == 'PC') {
  textField = true;
}
system.assertEquals(textField, true);

Find more details in https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm
Nisha Babu 8Nisha Babu 8
Hi Bala

Thank You for the suggestion.
Dynamically I have to take fields.
I can't specify the field name.

With Regards,
    Nisha
Kofi A. JohnsonKofi A. Johnson
SObjectType csType = Schema.getGlobalDescribe().get('YOUR_CUSTOM_SETTINGS_NAME');
Map<String,Schema.SObjectField> csfields = csType.getDescribe().fields.getMap();
System.debug(csfields.keySet());
Try the code above, and replace the YOUR_CUSTOM_SETTINGS_NAME with the Api Name of your Custom Settings. 
 
Nisha Babu 8Nisha Babu 8
Hi Kofi,

Thank You for the help.
Actually I have to take some of the fields from the keySet() and have to add it a new map.
How to do that.


With Regard,
   Nisha
Nisha Babu 8Nisha Babu 8
Hi ,

How to get the value for an field from the keySet().
I don't want the value for all fields but  value for some fields in the object.
And I have to store the selected key and value to another map.