I have made a method in my main class for custom settings

public static List<Color_Coding__c> colorCoding {
     get {
      if (colorCoding == null) {
             colorCoding = Color_Coding__c.getAll().values();
      return colorCoding;
      private set;

It is returning a list of custom settings.in my main class I have used the list with index. I want to know that whether we can automate custom settings I mean clients requirement may be different we are not going to make changes in class for that. Can we make some generic method for custom settings.

  • Can you put more use cases? I am not sure why you need to make that generic from your question as it is now
    – kurunve
    Jul 21, 2016 at 6:59
  • @kurunve actually I am working on a product. Each client will have different requirement for that I want to make a generic method....
    – Anzar
    Jul 21, 2016 at 7:03
  • Can you make few examples of requirements? Custom settings may be queried the same way as SObjects,, via dynamic soql, for example
    – kurunve
    Jul 21, 2016 at 7:05
  • if(r.count > colorCoding[3].Min_Value__c && r.count<=colorCoding[3].Max_Value__c) I have these conditions in my class. Based on these conditions the color of cell will change now each client will have different requirement with colors some some will say I want no color in that case we wont be able to make change in our class. Are you getting my point
    – Anzar
    Jul 21, 2016 at 7:06
  • That is still not clear what are you trying to achieve, the entire process below those custom settings. I think you should put your color inside Custom settings, and then if those are empty -- you can skip setting cell color, for example
    – kurunve
    Jul 21, 2016 at 8:03

1 Answer 1


Try to avoid hard-coded logic in apex code as it would give you inconsistent results. As you have mentioned, the custom setting will be used by different clients, in this case each client will set up their own data in the custom setting. By doing this, each customer might have different data in their custom setting and apex code will not be supportive for the that data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .