1

We have custom label whose length is about to reach 1000 characters, and we are using that custom label in APEX. Is there alternative available to this problem so that custom label can be replaced with something else and available in APEX too?

Thank you

Background:

We need to use custom label to give control to admin and also on different env the label value is different. So if I use that in code level then it is not controllable on different envs. Label contains record type ids with | separation and then we use it in APEX to perform the desired action.

6
  • You could use a string constant, e.g. public static String LONG_TEXT = 'Lorem ipsum...'. – Eduard Apr 1 at 8:35
  • Taking the suggestion by @Eduard one step further: you could use a string constant that is the concatenation of two custom labels. – Sander de Jong Apr 1 at 8:57
  • It entirely depends on just what you are using this label for; I recommend you edit your question to explain the requirement that lead to the use of a label. You could be able to use string format combination of multiple labels into a single string (where the format combination is also a label, like "{0} {1}", since this then allows you to change how the concatenation works if a language requires different ordering of the parts). You might even be able to use email templates or similar. Like I said, totally depends what you're trying to do. – Phil W Apr 1 at 9:20
  • We need to use custom label to give control to admin and also on different env the label value is different. So if I use that in code level then it is not controllable on different envs. Label contains record type ids with | separation and then we use it in APEX to perform the desired action. – Kamran Jabbar Apr 1 at 10:17
  • 1
    Please edit your question to add the explanation. – Phil W Apr 1 at 11:09
4

Labels exist to allow text to be presented in different locales for multi-lingual orgs.

You should never use labels to hold per-org configuration. Instead you should use Custom Metadata Types or Custom Settings to hold this configuration.

The benefit of Custom Metadata Types is that you can include the instances in Change Sets and these instances are automatically copied along with other metadata to Sandboxes, unlike Custom Settings which are treated as data (so only appear on partial or full Sandboxes when creating or refreshing them).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.