In an apex class I have a custom pick list whose values are displayed depending on profile. But now I want to remove the hard-coded profile names being used in the code. For that I am creating a hierarchical custom setting but the data to be stored in the field is more than 255 characters so I am not able to do that. And as I want data to be dynamically displayed so I cannot use custom label or custom object. What can I do to solve this problem. Please help.

Thanks, Rohit

  • 2
    try custom meta data Commented Jul 25, 2016 at 7:33

2 Answers 2


Not elegant, but assuming you only need say 1k or 2k characters of space in total, you can add multiple 255 character fields to the custom setting called e.g. Entries0, Entries1, Entries2, Entries3 etc and join them up in code:

    String[] entries = entries(new String[] {

private String[] entries(String[] parts) {
    String[] result = new String[] {};
    for (String part : parts) {
        if (!String.isEmpty(part)) result.addAll(part.split(','));
    return result;

This keeps the ability to have separate values per profile via the hierarchical custom setting mechanism.


Another approach is to just hold the name of a static resource in the custom setting. That allows the name to be varied per profile, and a static resource can be up to 5M in size. The code then also has to query the static resource:

String[] entries = new String[] {};
for (StaticResource sr : [
        select Body
        from StaticResource
        where Name = :MyCustomSetting__c.getInstance().StaticResourceName__c
        ]) {
  • Thanks for the suggestion but the problem with multiple fields is if later on data for the fields increases then I would have to create more field. With that I have to make changes in the code also. That is the thing I don't want. I need something that doesn't need changes in the codes afterwards even if the data changes or increases. Commented Jul 25, 2016 at 9:07
  • @RohitKhetan If you want to allow up to 5M of data, see the PS.
    – Keith C
    Commented Jul 25, 2016 at 9:12
  • If I store a static resource name in the custom setting then how can I get data as a pick list value? Commented Jul 25, 2016 at 9:25
  • @RohitKhetan Use the name to query the static resource body then split the values then turn them into SelectOption[] in your controller and present those values via apex:selectOptions.
    – Keith C
    Commented Jul 25, 2016 at 9:45
  • @ Keith C I am not getting how to store the name of static resource in the custom setting field. Can you help me with that. Commented Jul 25, 2016 at 10:13

Instead of custom settings, you can use Custom Metadata settings.


Custom metadata supports Text Area


Text Area (Long) is now available in Custom metadata types.

Allows users to enter up to 131,072 characters on separate lines.

  • Text Area on Custom Metadata also is limited to 255 characters.
    – rmarq423
    Commented Apr 11, 2018 at 16:56
  • Text Area (long) is supported in Custom metadata types. @rmarq423
    – sfdcFanBoy
    Commented Apr 12, 2018 at 4:44

You must log in to answer this question.

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