1.

Other Than Soql And Sosl What Is Other Way To Get Custom Settings?

Answer»

Other than SOQL or SOSL, Custom settings have their own set of methods to access the record.

For example:If there is custom SETTING of name ISO_Country,

SO_Country__c code = ISO_Country__c.getInstance(‘INDIA’);

//To RETURN a map of data SETS defined for the custom OBJECT (all records in the custom object), //you would use:

Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll();

// display the ISO code for India

System.debug(‘ISO Code: ‘+mapCodes.get(‘INDIA’).ISO_Code__c);

//Alternatively you can return the map as a list:

List<String> listCodes = ISO_Country__c.getAll().values();

Other than SOQL or SOSL, Custom settings have their own set of methods to access the record.

For example:If there is custom setting of name ISO_Country,

SO_Country__c code = ISO_Country__c.getInstance(‘INDIA’);

//To return a map of data sets defined for the custom object (all records in the custom object), //you would use:

Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll();

// display the ISO code for India

System.debug(‘ISO Code: ‘+mapCodes.get(‘INDIA’).ISO_Code__c);

//Alternatively you can return the map as a list:

List<String> listCodes = ISO_Country__c.getAll().values();



Discussion

No Comment Found