function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Madhuri V 5Madhuri V 5 

Hi,Input AccName and AccIndustry. Search for Accounts in comp1.displaying contacts and optys. AppEvt--> holding accId Comp1->evt fired,comp2->evt handeled,comp3->evt handled Issues:first succussful search result are still displaying even after changed the

User-added image
Raghu NaniRaghu Nani
Hi Can you share the code, So i will try to debug, Why component is not refreshing..
Madhuri V 5Madhuri V 5
Event :Event_Ex6.evt
<aura:event type="APPLICATION">
    <aura:attribute name="accountId" type="String" />
</aura:event>
Application:
<aura:application extends="force:slds">
    <c:LComp_AppEvent_AccSearch_Conts_Oppts_ParentComp_Ex2 />
</aura:application>
Parent Component:LComp_AppEvent_AccSearch_Conts_Oppts_ParentComp_Ex2 
<aura:component >
    <c:LComp_AppEvent_AccSearch_Child1_Ex2 /><br/><br/>
    <c:LComp_AppEvent_ContsList_Child2_Ex2 /><br/><br/>
    <c:LComp_AppEvent_OpptsList_Child3_Ex2 />
</aura:component>
Child Component 1: LComp_AppEvent_AccSearch_Child1_Ex2 
<aura:component controller="Lightning_AccSearch_Conts_Oppts_Ex2" >
    <aura:attribute name="accName" type="String" />
    <aura:attribute name="accIndustry" type="String" /> 
    <aura:attribute name="accountId" type="String" />
    <aura:attribute name="errorMessage" type="String" />
    
    <aura:registerEvent name="appEvent" type="c:Event_Ex6" /> 
    
	<lightning:card title="Search Account">
        <aura:set attribute="actions">
            <lightning:button label="Search" onclick="{!c.searchAcc}" />
        </aura:set>
        <lightning:input label="Account Name" value="{!v.accName}" />
        <lightning:input label="Industry" value="{!v.accIndustry}" />
        
        <br/>
        accountId : {!v.accountId}<br/>
        errorMessage : {!v.errorMessage}<br/>
    </lightning:card>
</aura:component>
Child 1 Controller:
({
	searchAcc : function(component, event, helper) {
		var accName=component.get("v.accName");
        var accIndustry=component.get("v.accIndustry");
        console.log(accName);
        console.log(accIndustry);
        var action=component.get("c.searchAccount");
        action.setParams({"accName":accName,"accIndustry":accIndustry});
        action.setCallback(this,function(response){
                	var state=response.getState();
                           if(state==='SUCCESS'){
            					var result=response.getReturnValue();
            					if(result!='Error'){
                					var accountId=result;
                                    console.log(accountId);
                                    component.set("v.accountId",accountId);
                                    var appEvent=$A.get("e.c:Event_Ex6");
                                    appEvent.setParams({"accountId":accountId});
                                    appEvent.fire();
                                    
            						}else
                                     var errorMessage='Opps!! No Account with your search data!!';
                               		 console.log(errorMessage);
                               		 component.set("v.errorMessage",errorMessage);
                               		 
        					}   		
                               
                      });
    		$A.enqueueAction(action);
	}
})
Child Component 2: LComp_AppEvent_ContsList_Child2_Ex2 
<aura:component controller="Lightning_AccSearch_Conts_Oppts_Ex2">
    <aura:attribute name="contacts" type="List" default="[]" />
    <aura:attribute name="columns" type="List" />
    
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    
    <aura:handler event="c:Event_Ex6" action="{!c.appEventHandler}" />
    
    <aura:if isTrue="{!not(empty(v.contacts))}">
    	<lightning:dataTable keyField="Id" data="{!v.contacts}" columns="{!v.columns}" hideCheckboxColumn="false" >
    	</lightning:dataTable>
    </aura:if>
</aura:component>
child 2 controller:
({
	appEventHandler : function(component, event, helper) {
		var accountId=event.getParam("accountId");
        console.log('accountId from comp2: '+accountId);
        var action=component.get("c.getContactList");
        action.setParams({"accId":accountId});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state==='SUCCESS'){
                var result=response.getReturnValue();
                console.log('result : '+result);
                component.set("v.contacts",result);
            }
        });
        $A.enqueueAction(action);
	},
    
    init  : function(component, event, helper) {
        var columns=[
            { label: 'First Name', fieldName: 'FirstName', type: 'text'},
            { label: 'Last Name', fieldName: 'LastName', type: 'text'},
            { label: 'Phone', fieldName: 'Phone', type: 'phone'},
            { label: 'Email', fieldName: 'Email', type: 'email'}
        ];
        component.set("v.columns",columns) ;
    }
})
Child Component 3: LComp_AppEvent_OpptsList_Child3_Ex2 
<aura:component controller="Lightning_AccSearch_Conts_Oppts_Ex2">
    <aura:attribute name="opportunities" type="List" default="[]" />
    <aura:attribute name="columns" type="List" />
    
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    
    <aura:handler event="c:Event_Ex6" action="{!c.appEventHandler}" />
    
    <aura:if isTrue="{!not(empty(v.opportunities))}">
    	<lightning:dataTable keyField="Id" data="{!v.opportunities}" columns="{!v.columns}" hideCheckboxColumn="true" >
    	</lightning:dataTable>
    </aura:if>
</aura:component>
child 3 controller:
({
	appEventHandler : function(component, event, helper) {
		var accountId=event.getParam("accountId");
        console.log('accountId from comp3: '+accountId);
        var action=component.get("c.getOpportuniesList");
        action.setParams({"accId":accountId});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state==='SUCCESS'){
                var result=response.getReturnValue();
                console.log('result : '+result);
                component.set("v.opportunities",result);
            }
        });
        $A.enqueueAction(action);
	},
    
    init  : function(component, event, helper) {
        var columns=[
            { label: 'Opportunity Name', fieldName: 'Name', type: 'text'},
            { label: 'StageName', fieldName: 'StageName', type: 'text'},
            { label: 'Amount', fieldName: 'Amount', type: 'currency'},
            { label: 'CloseDate', fieldName: 'CloseDate', type: 'date'}
        ];
        component.set("v.columns",columns) ;
    }
})
Apex class:  Lightning_AccSearch_Conts_Oppts_Ex2 
public class Lightning_AccSearch_Conts_Oppts_Ex2 {
    @AuraEnabled
    public static String searchAccount(String accName,String accIndustry){
        String accId;
        System.debug('accName : '+accName);
        System.debug('accIndustry : '+accIndustry);
        List<Account> accounts=[select Id,Name,Industry from Account where Name=:accName and Industry=:accIndustry];
        System.debug('accounts : '+accounts);
        System.debug('accounts.size : '+accounts.size());
        if(accounts.size()>0){
            System.debug('accounts[0].id : '+accounts[0].id);
            accId=accounts[0].id+'';
            System.debug('accId : '+accId);
        }else{
            accId='Error';
            System.debug('accId : '+accId);
        }
        System.debug('accId : '+accId);
        return accId;
    }
    @AuraEnabled
    public static List<Contact> getContactList(String accId){
        List<Contact> contacts=[select LastName,FirstName,Phone,Email from Contact where AccountId=:accId];
        System.debug('contacts apx : '+contacts);
        return contacts;
    }
    @AuraEnabled
    public static List<Opportunity> getOpportuniesList(String accId){
        List<Opportunity> opportunities=[select Name,StageName,Amount,CloseDate from Opportunity where accountId=:accId];
        System.debug('opportunities apx : '+opportunities);
        return opportunities;
    }

}

Hi Raghu,  Thanks for reply. attached the code.