I want to store app information like license type, number of guests users, license based app restrictions etc. I am looking for the following features along with this.

  1. This information should be visible to the user in the managed package but not editable (of course).

  2. The information can only be edited by the system admin (i.e. he can change the license type and restrictions).

  3. The info also needs to be accessed by Apex code, to read from it and possibly update fields in the future.

I am leaning on using custom metadata types. But so far it does not have any support for apex. I can use a custom object but I do not want to waste it for creating a single settings record. I am confused on how to go about this.

Any suggestions?

1 Answer 1


Custom Settings are the appropriate mechanism for this. There are plenty of cases where I've had to create custom settings that contained only a single record of data. If you're really feeling guilty about it, you could make a general "global variable" list type custom setting, where Name is the name of the "variable", and a field called Value stores some arbitrary data. You could then add any number of rows to this configuration custom setting as you add additional features to your code.

You can set the settings to "protected", meaning they can only be updated by system administrators through a mechanism you define (a Visualforce page), do not use a "custom object" (they're a separate type of metadata), can be queried "for free" in your code, and can be updated through Apex Code. You could even write a simple framework to use in your code for the custom setting:

public class GlobalVariable {
    public static String get(String variableName) {
        if(GlobalVariable__c.getInstance(variableName) != null) {
            return GlobalVariable__c.getInstance(variableName).Value__c;
        return null;
    public static void set(String variableName, String value) {
        upsert new GlobalVariable__c(Name = variableName, Value__c = value) GlobalVariable__c.Name;
  • Cool, I will create protected custom settings and create a visualforce page to access it. Jan 8, 2016 at 16:28

You must log in to answer this question.

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