0

Error

This page has an error. You might just need to refresh it.
Action failed: c:LC_1503_Ev_C2$controller$showme [Cannot read property 'config' of undefined]
Callback failed: apex://CL_1503_Ev/ACTION$searchacc
Failing descriptor: {c:LC_1503_Ev_C2$controller$showme}

Class

public class CL_1503_Ev {
@AuraEnabled
    Public Static String searchacc(String Nm, String Ind){
        String Res;
        List<Account> Accnts = [Select Id,Name,Phone,Rating from Account where name=:Nm and Industry=:Ind];
        if(Accnts.size()==0)
        {
            Res='NoData';
        }
        else{
            Res=Accnts[0].Id;
        }
        Return Res;
    }
    @AuraEnabled
    Public Static List<Contact> getcontacts(String lid){
        List<Contact> con1=[Select FirstName,LastName,Email from contact where AccountId=:lid];
        Return con1;
    }
     @AuraEnabled
    Public Static List<Opportunity> getopp(String lid){
        List<Opportunity> op1=[Select Name,StageName,Amount from Opportunity where AccountId=:lid];
        Return op1;
    }                                                                                                
}

Event

<aura:event type="APPLICATION">
    <aura:attribute name="accId" type="String"/>
</aura:event>

Component 1

<aura:component controller="CL_1503_Ev">
    <aura:attribute name="accName" type="String"/>
    <aura:attribute name="accInd" type="String"/>
    <aura:registerEvent name="novalue" type="c:LE_1503_Ev"/>
    
    <lightning:card title="Account Search">
        <lightning:input label="Enter the Name to Search" value="{!v.accName}"/>
        <lightning:input label="Enter the Industry to Search" value="{!v.accInd}"/>
        <lightning:button label="search" onclick="{!c.searchme}"/>
    </lightning:card>
</aura:component>

Controller 1

({
    searchme : function(component, event, helper) {
        var name=component.get("v.accName");
        var indust=component.get("v.accInd");
        
        var action=component.get("c.searchacc");
        action.setParams({"Nm":name,"Ind":indust});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state=='SUCCESS'){
                var result=response.getReturnValue();
                if(result!='NoData'){
                    var evt=$A.get("e.c:LE_1503_Ev");
                    evt.setParams({"accId":result});
                    evt.fire();
                }
            }
        });
        $A.enqueueAction(action);
    }
})

Component 2

<aura:component controller="CL_1503_Ev" >
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="colm" type="List"/>
    
    <aura:handler event="c:LE_1503_Ev" action="{!c.showme}"/>
    <lightning:card title="Contact Data">
        <lightning:datatable keyField="id" data="{!v.data}" coloumns="{!v.colm}"/>
    </lightning:card>
</aura:component>

Controller 2

({
    showme : function(component, event, helper) {
        var cl=[{label:"First name", fieldName:"FirstName"},
               {label:"Last name", fieldName:"LastName"},
               {label:"Email", fieldName:"Email"}];
        component.set("v.colm",cl);
        
        var eaid=event.getParam("accId");
        
        var action = component.get("c.getcontacts");
        action.setParams({"lid":eaid});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state=='SUCCESS')
            {
                var result = response.getReturnValue();
                component.set("v.data",result);
            }
        });
        $A.enqueueAction(action);
    }
})

Component3

<aura:component controller="CL_1503_Ev" >
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="colm" type="List"/>
    
    <aura:handler event="c:LE_1503_Ev" action="{!c.showme}"/>
    <lightning:card title="Opportunity Data">
        <lightning:datatable keyField="id" data="{!v.data}" coloumns="{!v.colm}"/>
    </lightning:card>
</aura:component>

Controller3

({
    showme : function(component, event, helper) {
        var cl=[{label:"Opp name", fieldName:"Name"},
               {label:"stage name", fieldName:"StageName"},
               {label:"Amount", fieldName:"Amount"}];
        component.set("v.colm",cl);
        
        var eaid=event.getParam("accId");
        
        var action = component.get("c.getopp");
        action.setParams({"lid":eaid});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state=='SUCCESS')
            {
                var result = response.getReturnValue();
                component.set("v.data",result);
            }
        });
        $A.enqueueAction(action);
    }
})

Application

<aura:application extends="force:slds">
    <lightning:layout>
        <lightning:layoutitem size="4">
            <c:LC_1503_Ev_C1/>
        </lightning:layoutitem>
        <lightning:layoutitem size="4">
        <c:LC_1503_Ev_C2/> 
        </lightning:layoutitem>
        <lightning:layoutitem size="4">
            <c:LC_1503_Ev_C3/>
        </lightning:layoutitem>
    </lightning:layout>
</aura:application>
0

This is caused by a typo in your declaration of the lightning:datatable columns.

<lightning:datatable keyField="id" data="{!v.data}" coloumns="{!v.colm}"/>

should be

<lightning:datatable keyField="id" data="{!v.data}" columns="{!v.colm}"/>

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.