Aura Component and JS Controller and Helper files are not resolving the API names of custom object and custom fields

In one of our Partner Dev Org, I am working on an application, after development and testing, I created a managed package

The steps I followed:

  • Developed code(Aura components, Apex Controllers) and created custom objects
  • After testing, Created unmanaged package and deployed in sandboxes and tested and working fine.
  • Observed that Lightning component with lightning datatable is displaying data in all columns
  • Created managed released package by defining namespace and also choosing the above already tested unmanaged package. It created managed package successfully
  • Observed Lightning component with lightning datatable is not displaying data in non of columns. It even didn't work in Package Development Org(Partner Dev Org). It didnt work in subscriber org

I am able to locate and find the root cause of the issue after spending 4 hours today:

The root cause is: Aura Component and JS Controller and Helper files are not resolving the API names of custom object and custom fields

Sample Code blocks from Application Code:


<lightning:datatable data="{!v.filteredAddrList}"                              
                         onsort="{!c.updateColumnSorting}" />

Javascript Controller and Helper code:

var actions = [
        { label: 'Details', name: 'show_details' }
    component.set('v.columns', [    
        {label:'Street', fieldName: 'Street__c', sortable : true, type:'text', initialWidth: 300, sortable: true},            
        {label:'City', fieldName: 'City__c', type: 'text', initialWidth: 300, sortable : true}

var selectedRows = component.get("v.existingItems");
        var newRequest = {
            Street__c: item
        newRequest.sobjectType  = 'Account_Address__c';

Above code snippets refer below custom objects and custom fields:

Custom Object: Account_Address__c Custom Fields: addressUniqueNumber__c, Street__c, City__c

Workaround: I did the changes and added package namespace prfix to all above custom object and fields names. Then the issue got resolved and the data is displayed in table.

addrverifyx__Account_Address__c addrverifyx__addressUniqueNumber__c, addrverifyx__Street__c, addrverifyx__City__c

It worked fine in both Package dev org and subcriber org. I dont this is the correct solution. There may be some other reason it is not working.

I searched many salesforce expert developer community forums and I didnt find the similar issues.

Is this the correct solution? Why it is failing to resolve the api names?

2 Answers 2


The "Organizations with a Namespace Prefix" section of Namespace Usage Examples and Reference confirms that you do need to include the namespace.

As sfdcfox says, one advantage of using Scratch Orgs is that you can develop with the namespace defined from day one, rather than having to add it at the end to package. (In Apex code, the namespace is injected by the platform when not specified so this problem is somewhat hidden in that case.)

  • 2
    If you are having to develop against dev orgs rather than scratch orgs and you happen to be using IntelliJ IDEA with Illuminated Cloud 2, this already has a namespace mapping mechanism which means you write the code with your target namespace but can deploy to dev orgs with different namespaces. (You would, of course, be much better off using SFDX.)
    – Phil W
    Commented Jan 14, 2020 at 8:00
  • Thank you Keith and Phil clarifying and explaining more details
    – Anil
    Commented Jan 15, 2020 at 18:58

That's not a workaround, that's the intended pattern for designing in LWC. It is for this reason that Scratch Orgs can be registered to a Namespace so that you don't have to keep adding/removing namespaces while developing your package.

  • Thank you sfdcfox clarifying and explaining more details
    – Anil
    Commented Jan 15, 2020 at 18:58
  • Does the scratch org with namespace solution work with Packaging 1? if not what could be the solution to make aura component work in both dev/scratch org and packaging org? Commented Dec 7, 2021 at 12:35
  • @balindersingh Yes, you can use the namespace in the Scratch Org for both types of development. In addition, if you use the import FIELD from '@salesforce/schema/ObjectName.FieldName' technique and use that import to reference the fields, they will automatically include the namespace, or not, depending on the context. This can be a better solution, but requires a little more code.
    – sfdcfox
    Commented Dec 7, 2021 at 12:42
  • awesome .. good to know that namespace can be used in scratch orgs even for packaging 1.. Does that mean I can use namespace prefix as I would use it in packaging org.. no exceptions? Commented Dec 7, 2021 at 13:15
  • And I assume , I need to link the namespace to devhub as well, right? Commented Dec 7, 2021 at 13:20

You must log in to answer this question.

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