1

We are trying to deploy our package, but a weird error is thrown:

enter image description here

The thing is, in that LWC, we are in fact NOT adding the namespace when importing those fields:

import PRODUCTO_FIELD from '@salesforce/schema/Producto_Orden_Compra__c.Producto__c';
import PROVEEDOR_FIELD from '@salesforce/schema/Orden_de_Compra__c.Cuenta__c';

If I try to add the namespace before the sObject and fields, the same error is thrown and I can't even deploy the changes to the org.

What am I supposed to do? Add the "c" namespace? But it would be wrong as these objects and fields are part of the ERPvs__ namespace. Is it a salesforce bug or am I missing something? This LWC was deployed as part of the package before without problems. Any help would be appreciated.

EDIT: tried adding the "c" namespace, but it didn't work. "invalid reference" is the error and I can't even deploy to the org. (tried with "c__" and "c.")

1 Answer 1

0

Yes, you're meant to use the c namespace. This is automatically translated to the correct namespace by the compiler when the component is delivered to the client (browser). This convention allows you to deploy your code to a non-namespaced org and into a namespaced package using the same source code. This makes development of packages easier for ISV developers.

2
  • It doesn't work. I tried adding "c." before the objects and fields and also tried "c__" and neither work, when trying to deploy, an error is thrown "invalid reference" Commented Jun 19 at 13:43
  • 1
    It is c- rather than either of the options you tried, but that's just for the LWC reference. Fields and objects do not need any namespacing when the LWC is in the same package as the fields and objects.
    – Phil W
    Commented Jun 19 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .