0

I'm trying to create my own Account Hierarchy link that displays more than 500 accounts and its children utlizing lightning componenets and lightning out. I keep recieving this error whenever testing that displays:

This page has an error. You might just need to refresh it. AuraClientService.postProcess: error in processing [Maximum call stack size exceeded]

Lightning Component:

<aura:attribute type="Account[]" name="acctList"/> <aura:attribute name="gridColumns" type="List" /> <aura:attribute name="gridData" type="Object" /> <aura:attribute name="gridExpandedRows" type="Object" />

<aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>

<lightning:treeGrid columns="{! v.gridColumns }"
    data="{! v.gridData }"
    keyField="Id"
    aura:id="mytree" /> 

Controller .js:

({
    fetchAccounts : function(component, event, helper) {
        var columns = [
            {
                type: 'text',
                fieldName: 'Name',
                label: 'Account Name'
            },
            {
                type: 'text',
                fieldName: 'Type',
                label: 'Type'
            },
            {
                type: 'text',
                fieldName: 'Account Status',
                label: 'Account Status'
            },
            {
                type: 'text',
                fieldName: 'LAM_Shipping_Address__c',
                label: 'Service Address'
            },
            {
                type: 'text',
                fieldName: 'OPCO__c',
                label: 'OPCO'
            },
            {
                type: 'text',
                fieldName: 'LAM_Account_Owner__c',
                label: 'Account Owner'
            },
            {
                type: 'text',
                fieldName: 'Rolling_12_Month_Total_Usage_kWh__c',
                label: 'Rolling 12 Month Total Usage kWh'
            }
        ];
        component.set('v.gridColumns', columns);
        var action = component.get("c.fetchAccts");
        action.setCallback(this, function(response){
            var state = response.getState();
            if ( state === "SUCCESS" ) {
                var data = response.getReturnValue();
                for ( var i=0; i<data.length; i++ ) {
                    data[i]._children = data[i]['Contacts'];
                    delete data[i].Contacts; 

                }
                component.set('v.gridData', data);
            }
        });
        $A.enqueueAction(action);
    }

})

Apex Controller:

public class AccountListController {

    @AuraEnabled
    public String currentsObjectId {get;set;}
    public id accId{get;set;}
    public String ids;

  /*  
    public AccountListController() 
    {
        currentsObjectId = Apexpages.currentPage().getParameters().get('Id');
        System.debug('currentsObjectId == ' +currentsObjectId);


    }

     @AuraEnabled public static List <Account> fetchAccts() {
        return [ SELECT Id, Name, OPCO__c, Rolling_12_Month_Total_Usage_kWh__c, LAM_Shipping_Address__c, LAM_Account_Owner__c, Rolling_12_Month_Total_Revenue__c, Account_Status__c  FROM Account LIMIT 1000 ];
    }
  */ 

        public AccountListcontroller()
        {
    //pass first account record Id 
    fetchParentRecord(accId);
        }

        //this method will iterate untill the parent Id is null
    private void fetchParentRecord(Id recordId)
    {
         //each time query on Account and get the get the parent Id
        List<Account> lstAccount = [SELECT ParentId, Id, Name, OPCO__c, Rolling_12_Month_Total_Usage_kWh__c, LAM_Shipping_Address__c, LAM_Account_Owner__c, Rolling_12_Month_Total_Revenue__c, Account_Status__c  FROM Account 
                                 WHERE Id =: recordId AND ParentId != null];
        // if list is not empty then based on parent Id get the next above Account
            if(!lstAccount.isEmpty()){
        ids = ids + ' : '  +lstAccount[0].parentId;
        fetchParentRecord(lstAccount[0].parentId);
    }
   }

}

Visualforce Page:

<apex:page standardController="Account">
    <apex:includeLightning />
    <style>
        html, body {
        margin: 0;
        padding: 0;
        }
        #lightningComponent {width: 100%;}
    </style>

    <div id="lightningComponent2"></div>
    <div id="lightningButton" />

    <script>
        $Lightning.use("c:AccountTreeApp",function(){

          $Lightning.createComponent("c:LAM_Hierarchy",{},"lightningComponent2", function(){});       
        });
    </script>

</apex:page>
New contributor
B Valentine is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Right now with the code you have posted there's nothing server-side that the Lightning component can call as your only @AuraEnabled method is commented out. Can you confirm that the Apex method name does not match the name of the method in the Component's controller? I ask because I've seen this error before when the component and Apex class's method names are identical. See here: salesforce.stackexchange.com/questions/130091/… – nbrown Feb 11 at 15:18

Your Answer

B Valentine is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.