0

I have a requirement to display all the child records of Account. Child is Managed Package Object, Named as "PCQQ__Quote__c". So I am getting the records from server but when I am doing component.set('v.quoteRecords',data), component is not loading, even though I can see the data in console. I am using the below attribute to hold the data:-

 <aura:attribute name="quoteRecords" type="List" />

I tried this one as well but it does not work

 <aura:attribute name="quoteRecords" type="PCQQ__Quote__c[]" />

I have done this kind of work with standard objects and custom objects many times but here not able to do so. Is there any specific trick for manage package data or do I need to manipulate the data in controller.js and put in an array and then display in component.

  • You must be missing something in your controller. As of now its not clear because you don't have the complete code in here. I was able to get records from an object from a managed package and was able to display that on the component. Note, it worked with all combinations of the type, viz., array of the object, list or object itself. – Jayant Das Sep 25 '18 at 21:14
0

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.

| improve this answer | |

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.