[SalesForce] Field Label and field name(API Name) best practice

Can field label be different to field names, of-course system allows us to change the label name but is it a good practice though ? would there be any problems if the Label and API name does not match .

eg: Field Label – 'FL Sales Tax Code', API Name – 'SalesTaxTextFLA__c'

Best Answer

One of the great things about changing a field label is that you can adapt your existing fields to a changed or evolving business understanding without the challenges of changing API names when those names are used by either Apex code, VF pages, or 3rd party integrations.

For example, you might start with a field with

  1. Label = Region
  2. API name = Region__c and apex code to exploit this

but the business might evolve and start calling Regions as "Segments"

You could change the label to be: "Segment (region)" during the transition period and after a few months change it to "Segment". The Apex code is unaffected.

Changing labels is also great when the original field API/label was poorly named. For example, I like to make many of my checkbox/boolean formula fields have labels like "Is xxx?" or "Has yyyy?" but often a legacy system didn't use this convention. I can easily change the label and not worry about the underlying API name if it is associated in some Apex code/VF page.

There are some downsides to changing labels:

  1. Integrations that rely on labels, notably systems that interpret the columns in a SFDC report like Conga or other Analytics API clients may/will fail
  2. VF pages that use pageBlockSectionItem plus inputField may need to be changed as the corresponding "label" (typically done by outputText value="someLabel") will need to be made consistent with your field metadata change.

Others may chime in with more caveats.

Related Topic