3

I use VS Code with Salesforce extensions and connect to my sandbox as explained here:

https://forcedotcom.github.io/salesforcedx-vscode/articles/user-guide/org-development-model

With my package.xml I fetched apex classes and custom labels from sandbox.

In settings I enabled push-or-deploy-on-save.

On saving and deploying I always get error messages where custom labels are used: "External string does not exist: MY_LABEL":

static final String MY_LABEL = Label.MY_LABEL;

My custom labels exist in the sandbox and in my project, so what causes this error?

Regards

1
1

Shouldn't you use System to call Custom Labels?

static final String MY_LABEL = System.Label.MY_LABEL;
1
  • no, System.Label gives same error, and code worked before I moved to VS code.
    – Obi_77
    Aug 28 '19 at 9:35
0

If the Custom Label is marked as a Protected Component, then you will not be able to access it outside the package in which it managed. As noted in the Salesforce Metadata API Docs, protected:

Indicates whether this component is protected (true) or not (false). Protected components cannot be linked to or referenced by components created in the installing organization.

You will either need to edit the label and uncheck the Protected Component attribute, or push a copy of the label in your namespace to have access to it in Apex.

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.