If your component is within the package you should not be referencing the object via the namespace like PCQQ__
is being used. You should have a Quote__c[]
instead.
In your Apex, if you are using generic SObject
type when populating your arrays, you may need to fetch your namespace dynamically as it will not be available to your code in your development org, but will be available when accessing the fields/ generic objects once installed in another org.
An easy way to pull the namespace would be:
public class MyController {
@AuraEnabled
public static String getMyNamespaceWithUnderscore(){
return !String.isBlank( getMyNamespace() ) ? getMyNamespace() + '__' : '';
}
@AuraEnabled
public static String getMyNamespace(){
return this.getName().contains( '.' ) ? this.getName().substringBefore( '.' ) : '';
}
}
In your package org - this will return '' and you will need not put this before any dynamic field / object reference in your code to access the object to return your list as your fields will not need the namespacing in this case. But, in other orgs using the package, this will allow your dynamic field / object names to be fetched with the proper namespace.
SObject record = new Quote__c();
String fieldName = getMyNamespaceWithUnderscore() + 'MyCustomField__c';
Object value = record.get( fieldName );
If using like this, would be a good idea to first check if the field exists on the object type by referencing the field describe Map for the object to see if the containsKey( fieldName )
returns true before accessing it.
In my experience I have found that in packages this would be necessary to returning records since the fields would not be found once installed in another org when using generic SObjects. Not doing so would cause my view to return no data for this case because my queries would fail once deployed without fetching namespace on the fly.
Hope it helps.
type
, viz., array of the object, list or object itself. – Jayant Das Sep 25 '18 at 21:14