I am able access the custom labels created in my org, using Apex, but not the custom labels from a managed package installed in my org. The documentation does not have a specific example to access namespaced custom labels in Apex. I am developing lightning components in a developer edition org (not scratch org).
I have tried the following ways:
System.Label.namespace.CustomLabelName
System.Label.namespace__CustomLabelName
Label.namespace.CustomLabelName
Label.namespace__CustomLabelName
and got the following error message:
External string does not exist: CustomLabelName
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/labels_apex.htm
Has anybody been able to access packaged custom labels from outside the package?
Best Answer
As noted in the comments...
The correct syntax is System.Label.Namespace.CustomLabelName.
This also requires the managed CustomLabel to have
protected
set tofalse
so the subscriber org can access it.