[SalesForce] Custom Labels – naming conventions – best practices

We're about to start refactoring a bunch of hard-coded text from a client's Lightning Components and Visualforce pages into Custom Labels so that they can support multi-language users. Unfortunately as you all know, these can't be sorted into folders or anything else better organized (although list view filters are possible).

Any thoughts on what makes for good naming conventions for a pile of Custom Labels? Some of these will represent one or two words, others entire phrases. Some of them will likely be reused between different pages.

Also because Lightning has no support for the same kind of $ObjectType.Account.Label syntax that Apex has, we'll probably have to also be storing some object and field name translations redundantly in Custom Labels. If our Lightning cmps were at a MUCH bigger scale I'd maybe consider building a custom service component to deliver object/field labels but that seems like overkill for the current project.

Best Answer

Even though it depends on teams to teams when it comes around best practices, but as for your question

Any thoughts on what makes for good naming conventions for a pile of Custom Labels?

I have usually taken an approach of reflecting the intent of the custom label in its name. Have also tried to keep the naming convention seamless so that it can be organized. I have mostly used below approach from best practices around naming conventions of custom labels:

  • Use uppercase letters
  • Separate words within the name using an underscore
  • Reflect the intent/characteristic of the label
  • Keep the overall length of the label name short

As an example, let's say if I have a some sort of legal text to be displayed somewhere, I would create a custom label as say, LEGAL_DISCLOSURE_TEXT. Similarly if I had something related to say finance, I would have it as FINANCE_COLLECTION_DAYS.

Again, it all depends on which approach you take, but usually starting right from design helps it from future maintainability and scale-ability perspective.

Related Topic