Wednesday, January 22, 2014

Other than SOQL and SOSL what is other way to get custom settings

Other than SOQL and SOSL what is other way to get custom settings

Other than SOQL or SOSL, Custom seting have there 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();


No comments:

Post a Comment