CustomLabel represents one named, localizable text value of up to 1,000 characters. Application code and declarative configuration can reference it to reuse wording without storing that wording in each consumer. Labels can also appear in formulas and conditions, so changing a label's text can change behavior, not just what users see.
Each CustomLabel is an individual component within the CustomLabels container's labels collection. Several labels can share one metadata file while retaining separate identities. The singular and plural types also have different retrieval behavior.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
Required. The label's API name and metadata identity. Specify it when creating, updating, or deleting the label. Neither its description nor its text replaces this identity. |
value |
Required. The label's text, with a maximum length of 1,000 characters. Consumers can display this value or use it in expressions. |
language |
Required. The language of the label's value. Additional localized values are managed through Translations. |
protected |
Required boolean: true or false. When true, components created in the installing organization cannot link to or reference the packaged label. |
shortDescription |
Required. A recognizable description used to identify the label, including in merge fields. It is not the label's metadata identity. |
categories |
An optional comma-separated list used to filter custom label list views. Maximum length: 255 characters. |
Behavior and Constraints
protected controls a package boundary, not merely whether users can edit the text. A protected packaged label cannot be referenced by subscriber-created code or configuration in the installing organization. This matters when packaged functionality expects subscribers to build their own consumers of its labels.
Changing value and changing fullName are different operations. A text update keeps the referenced component's identity. A name change affects the identity that consumers reference. The label definition itself does not identify all consumers, particularly references embedded in code, formulas, and Flow expressions.
A label value is not necessarily display-only text. Apex, formulas, validation expressions, and flows can use label text in calculations or conditions. A wording change can therefore affect those consumers even when the label name stays the same.
The label's value and language describe its text and language. Additional localized entries belong to Translations, where each entry references the label through name.
Deployment and Retrieval
Choose the manifest type according to the retrieval scope:
-
Selected labels: Use
CustomLabelinpackage.xml, with each label'sfullNameas a member. For example, use membersquoteManualandquoteAutoto retrieve those two labels. -
All labels: Use
CustomLabelswith the wildcard member*to retrieve all custom labels defined in the organization.
The CustomLabels container does not support retrieving selected labels by name, and it cannot be retrieved with a namespace. These are container restrictions; do not treat the plural container as the retrieval identity of an individual label.
In Metadata API format, master label values are stored in CustomLabels.labels. Multiple labels entries in that file remain separate named components. Editing an existing file to add a label still adds a component, which matters for managed-package patch restrictions reported below.
Retrieving master labels alone does not produce a complete multilingual export. Retrieve the translated values through Translations as well. Translation files are stored in the translations folder and use the naming pattern localeCode.translation, where localeCode identifies the translation language.
For creation, update, or deletion, identify the individual label by fullName. Rename and deletion impact depends on the actual consumers, including references embedded in source files and expressions, rather than just the contents of the shared labels file.
Relationships
CustomLabels contains individual labels through labels, while Translations supplies additional localized values. Consumers can reference labels through metadata elements or within source content. The filedata entries below identify embedded source references that need not appear as standalone metadata reference fields. These are possible connections, not proof that a particular label is used.
Referenced By
-
ApexClass:filedata -
ApexComponent:filedata -
ApexPage:filedata -
ApexTrigger:filedata -
ApprovalProcess:formula -
ChoiceList:customLabel -
CustomField:formula -
CustomObject:errorConditionFormula,formula, in contained field and validation definitions -
EmailTemplate:filedata -
EmbeddedServiceMenuSettings:customLabel -
Flow:assignToReference,elementReference,expression,fieldText,filterFormula,interviewLabel,leftValueReference -
LightningBundle:filedata -
LightningWebComponent:filedata -
OauthCustomScope:description -
Translations:name -
ValidationRule:errorConditionFormula
Reported Issues
- A new label can prevent a managed-package patch. A 2017 discussion reports that adding a label is prohibited because it adds a component, even when the only file change is to an existing shared labels file. File storage does not determine the component boundary. Managed-package patch discussion.
-
Direct Apex assignment does not update label metadata. In a 2014 report, assignments to
Label.myLabelandSystem.Label.myLabelfailed with "Expression cannot be assigned". Updating a label through Setup or Metadata API is distinct from assigning a runtime variable. Apex assignment discussion. -
Missing spaces in concatenated messages can originate in saved label values. A 2018 report describes leading and trailing spaces being trimmed when labels were saved. The answers recommend supplying separators in consuming code or using
String.formatwith a translatable template and positional placeholders such as{0}and{1}. A translated template can also reorder the message parts. Whitespace and message formatting discussion. -
A validated label deployment can still fail at quick deployment. In a 2020 report involving a new production organization without Apex classes or tests, validation requested
RunLocalTests, but quick deployment failed with "INVALID_ID_FIELD: Source validate did not run tests in the org". The author reported success with a direct deployment usingRunLocalTests, without the staged quick-deployment step. This is not evidence that every label-only deployment requires tests. Label deployment and quick-deploy discussion. -
A label parsing error can appear during retrieval of unrelated metadata. A 2024 report describes "Missing fullName on CustomLabel" naming
CustomLabels.labels-meta.xmlwhile the user retrieved other metadata, as well as labels themselves. No confirmed cause or resolution was reported. Missing fullName retrieval report. -
Line-ending normalization can affect text stored inside a label. A 2023 report describes a label containing a carriage-return and line-feed pair, or CRLF, inside its
value, while the surrounding retrieved XML used line-feed-only endings. The concern was that normalizing the file could alter the stored text used by formulas. No confirmed remedy was reported. Mixed line-ending report. -
Visualforce label expressions do not evaluate inside a separate static JavaScript resource. In a 2014 discussion, answers passed the evaluated label text from the Visualforce page into JavaScript variables or attributes instead. The variable-based example used
JSENCODEwhen inserting label text into JavaScript strings. Labels in static JavaScript discussion. -
A label containing an object API name does not become an object reference. A 2016 custom-button discussion explains that concatenating a label value such as
CustomObject__cwith.Idproduces text, not an evaluated record-field reference. Label text in button expressions. - An explicit default-language translation reportedly corrected an unexpected language in a Lightning web component. In a 2020 answer, the component displayed an English translation despite selection of the label's default language. Adding a translation entry for the default language reportedly restored the expected text. This is a conditional workaround, not a general requirement to duplicate every master value as a translation. Lightning label translation discussion.
Common Questions
How do I retrieve one custom label instead of all labels?
Use the singular CustomLabel type in package.xml and specify the label's fullName as the member. Use CustomLabels with * for all labels; the plural container does not support selected names.
Does retrieving CustomLabels include all translations?
No. Retrieve additional localized values through Translations. Master values are stored in CustomLabels.labels, while translation files use localeCode.translation under the translations folder.
Can I add a custom label in a managed-package patch?
The reported restriction is that a new label adds a component and is therefore prohibited in a patch. Adding it to an existing labels file does not change that component boundary.
Can Apex change a custom label by assigning System.Label.myLabel?
Direct assignment was reported to fail with "Expression cannot be assigned". A label metadata update through Setup or Metadata API is a different operation from assigning a value in Apex.
Can changing a custom label value break logic?
Yes, when a consumer uses the text in a calculation or condition. References can occur in Apex, formulas, validation expressions, flows, and other source content, so a value change is not necessarily cosmetic.