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
Richard Houston GMURichard Houston GMU 

Start a timer when child component loads

Hi,

I'm trying to add a timer to individual cases when they're added to the queue and displayed in a lightning component. I thought I could simply fire an "init" on the child component to execute a JS timer. However, it's not loading the function. 

Thanks for any help!

Business need, display a list of cases in the queue and how long they have been in that queue.

Child component name: Case Tile
Parent component name: Case List

Child component:
<aura:component >
	<aura:attribute name="case" type="case"/>
    
    <aura:registerEvent name="navigateToSObject" type="force:navigateToSObject"/>
    <aura:registerEvent name="selectSObject" type="ltng:selectSObject"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
        <lightning:card >        
            <aura:set attribute="title" >
            	<a onclick="{!c.caseSelected}" style="color: black; ">
                    <div class="slds-align_absolute-center">
                    Name: <aura:if isTrue="{#v.case.Contact.Name!=undefined}">                        
                        {#v.case.Contact.Name}
                        <aura:set attribute="else">
                            {#v.case.SuppliedName}
                        </aura:set>
                    </aura:if>
                    </div>
                </a>
        	</aura:set>
           
            <a onclick="{!c.caseSelected}" style="color: black; ">
                
                <p class="slds-p-horizontal--small">
                	Requested Advisor: {#v.case.Requested_Advisor_Counselor__c}                
            	</p>
                <p class="slds-p-horizontal--small">
                	Type: {#v.case.Type}
                </p>
                <p class="slds-p-horizontal--small">
                    Time in queue: <ui:outputNumber value="{#v.case.Total_minutes_in_the_queue__c}" />
                </p>                
           </a> 
    </lightning:card>
</aura:component>
Child controller: 
({
    
    doInit : function(component){
        console.log('Do an action but nothing happens');
        
    }
})


Parent component:
<aura:component controller="CaseTileController" implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="cases" type="Case[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="c:QueueChange" action="{!c.onQueueChange}" />
    <aura:attribute name="selectedQueue" type="string" />
    <c:streaming channel="/event/CaseChange__e" onMessage="{!c.eventFired}" />
    <lightning:layout horizontalAlign="left" class="slds-theme_shade">
        <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<lightning:icon iconName="standard:case" size="medium" alternativeText="Case Queue" class="slds-p_small" />
            <span class="slds-text-heading_medium"> &nbsp; Case Queue</span>
        </lightning:layoutItem>
   		<lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<c:QueueSelector /> 
        </lightning:layoutItem>
    </lightning:layout>
    <lightning:layout horizontalAlign="left" multipleRows="true" title="Case Queue" class="slds-theme_shade">        
        <aura:if isTrue="{!(v.cases != null)}" >            
            <aura:iteration items="{!v.cases}" var="c" >
                <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
                    <c:caseTile case="{#c}" />
                </lightning:layoutItem>
            </aura:iteration>
            <aura:set attribute="else">
                <div class="slds-align_absolute-center" >
                    <div class="empty-state-container slds-text-align_center" >
                        <img src="/projRes/ui-home-private/emptyStates/noTasks.svg" />
                        <div class="empty-state-message slds-m-top_medium" style="margin-bottom: 1rem;" >                            
                            Check back later, there are no current cases in the queue.
                        </div>
                    </div>
                </div>
            </aura:set>
        </aura:if>
    </lightning:layout>

</aura:component>
Parent controller: 
({
	doInit : function(component, event, helper) {        
       helper.getCases(component);

	},

    eventFired : function(component, event, helper){
		helper.getCases(component);
       
     },
    
    onQueueChange: function(component, event, helper){
        component.set("v.selectedQueue", event.getParam("selectedQueue"));
        helper.getCases(component);
    }
})

Parent helper:
({
	checkForChanges : function(component, event, helper) {
		var action = component.get("c.getAvailableCases");
        action.setCallback(this,function(data){
           component.set("v.cases",data.getReturnValue()); 
        });
        $A.enqueueAction(action);
	},
    
    getCases : function(component, page){
        var action = component.get("c.getAvailableCases");
        action.setParams({
            "queueSelection" : component.get("v.selectedQueue")
        });
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var results = response.getReturnValue(); 
                component.set("v.cases",results);
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
           
        });
        
        $A.enqueueAction(action);
    }
})



 
KdKomalKdKomal
Hi Richard,

Could you please replace <c:caseTile case="{#c}" /> with <c:caseTile case="{!c}" /> and let me know if it solves the issue ?
Richard Houston GMURichard Houston GMU
Hi Komal,

Thanks for the reply. I made the modificatoin, however the caseTileController is still not firing the init. 
KdKomalKdKomal
Hi Richard,

Could you please make below changes  :-
1- Add an boolean Attribute - <aura:attribute name="isDataReturned" type="boolean" default="false"/>
2-Change getCases function in your helper :-
component.set("v.cases",results); 
component.set("v.isDataReturned", true);
3- Change your aura if on line no 17 to - <aura:if isTrue="{!v.isDataReturned}">

Let me know if these resolves it or not.
Richard Houston GMURichard Houston GMU
Komal,

That still didn't get the init function to fire. But it did improve the page speed! Which is a good thing. 
KdKomalKdKomal
Hi Richard, 
Are you getting the message "Do an action but nothing happens" in your console log? 
KdKomalKdKomal
Could you please add a console.log/alert after component.set("v.isdatareturned  true) displaying the value of the result. 
Richard Houston GMURichard Houston GMU
Strange, I'm not seeing the log of the results variable in the caseListController or the "Do an action..." in my caseTileController

Current markup of caseTileController:
 
({
    doInit : function(component, event, helper){
        console.log('Do an action but nothing happens');
        alert('Loaded the set timer function');
       

    },
    
    navigateToDetailsView : function(component) {
        var c = component.get("v.case");
        console.log(c);
        var myEvent = $A.get("e.force:navigateToSObject");
        myEvent.setParams({
            "recordId": c.Id
        });
        myEvent.fire();
        console.log(myEvent);

	},

	caseSelected : function(component) {
        
		var c = component.get("v.case");
        console.log(c);
        var myEvent = $A.get("e.ltng:selectSObject");
        console.log(myEvent);
        myEvent.setParams({"recordId": c.Id, channel: "Cases"});
        myEvent.fire();
    }
   
})

Current markup of CaseListHelper:
 
({
	checkForChanges : function(component, event, helper) {
		var action = component.get("c.getAvailableCases");
        action.setCallback(this,function(data){
           component.set("v.cases",data.getReturnValue()); 
        });
        $A.enqueueAction(action);
	},
    
    getCases : function(component, page){
        var action = component.get("c.getAvailableCases");
        action.setParams({
            "queueSelection" : component.get("v.selectedQueue")
        });
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var results = response.getReturnValue(); 
                component.set("v.cases",results); 
                component.set("v.isDataReturned", true);
                console.log('Value of results: '+ results);
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
           
        });
        
        $A.enqueueAction(action);
    }
})


CaseListController: 
 
({
	doInit : function(component, event, helper) {        
       helper.getCases(component);


	},

    eventFired : function(component, event, helper){
		helper.getCases(component);
      
     },
    
    onQueueChange: function(component, event, helper){
        component.set("v.selectedQueue", event.getParam("selectedQueue"));
        helper.getCases(component);
    }
})

 
KdKomalKdKomal
Can you please show me your getAvailableCases method under the apex controller - CaseTileController
Richard Houston GMURichard Houston GMU
I changed it to an alert in the helper and received the message. It displayed as:

User-added image

Sure thing here's the apex controller:
 
global with sharing class CaseTileController {

    @RemoteAction @AuraEnabled
    public static Case[] getAvailableCases(String queueSelection){
        system.debug(queueSelection);
        List<Profile> CProfile = [select id, name from Profile where id =:userinfo.getProfileId() limit 1];
        String userProfileName = CProfile[0].name;
        String queueType;
        IF(queueSelection != null && queueSelection != ''){
                queueType = queueSelection;
            }else iF(userProfileName == 'GMU - Academic Services User'){
                queueType = 'Academic Advising Requests Queue';
            }else if(userProfileName == 'GMU - Career Services User'){
                queueType = 'Career Consulting Requests Queue';
            }else {
                queueType = 'Academic Advising Requests Queue';
            }
        List<Case> c = new List<Case>();
        system.debug('Value of queueType ' + queueType);
        c = [select 
                    Id, 
                    Subject, 
                    Status, 
                    CaseNumber, 
                    Contact.Name,
             		Contact.id,
             		Contact.G_Number__c,
             		Web_G_Number__c,
                    Owner.Name, 
                    OwnerId, 
                    Total_minutes_in_the_queue__c,
                    Requested_Advisor_Counselor__c,
                	Student_Services_Office__c,
                	SuppliedName,
             		CreatedDate,
                	Type,
             		Contact.hed__FERPA__c,
             		Contact.IOC__c
                	
                from Case 
                where isClosed=false and
                	  owner.Name  =: queueType
               	ORDER BY createddate asc
               ];
        if(c.size() == 0){
            return null;            
        }else{
            system.debug('Value of c: '+c);
			return c;            
       }
}

 
KdKomalKdKomal
Add JSON.stringify(result ) and it will show the data in Json. Please verify if that is the  Correct data or not 

What is the purpose of streaming component ? 
Richard Houston GMURichard Houston GMU
It is the correect and expected data:

User-added image

The streaming component is to handle new/updated cases and to refresh the component. It is from this project: 

https://github.com/afawcett/streamingcomponent/tree/master
KdKomalKdKomal
If you are getting this response which means your apex controller is working fine. Could you please for one more time share your updated component mark up.
Richard Houston GMURichard Houston GMU
Sure thing, here's all of the current components. Thanks for taking the time to review all of this! 

caseTile Component markup:
<aura:component >
	<aura:attribute name="case" type="case"/>
    <aura:handler name="init" value="{!v.case}" action="{!c.doInit}" /> 
    <aura:registerEvent name="navigateToSObject" type="force:navigateToSObject"/>
    <aura:registerEvent name="selectSObject" type="ltng:selectSObject"/>
        <lightning:card >        
            <aura:set attribute="title" >
            	<a onclick="{!c.caseSelected}" style="color: black; ">
                    <div class="slds-align_absolute-center">
                    Name: <aura:if isTrue="{#v.case.Contact.Name!=undefined}">                        
                        {#v.case.Contact.Name}
                        <aura:set attribute="else">
                            {#v.case.SuppliedName}
                        </aura:set>
                    </aura:if>
                    </div>
                </a>
        	</aura:set>
           
            <a onclick="{!c.caseSelected}" style="color: black; ">
                
                <p class="slds-p-horizontal--small">
                	Requested Advisor: {#v.case.Requested_Advisor_Counselor__c}                
            	</p>
                <p class="slds-p-horizontal--small">
                	Type: {#v.case.Type}
                </p>
                <p class="slds-p-horizontal--small">
                    Time in queue: <ui:outputNumber value="{#v.case.Total_minutes_in_the_queue__c}" />
                </p>
                <label aura:id="minutes">00</label>:<label aura:id="seconds">00</label>
                
           </a> 
            <!--<lightning:button onclick="{!c.changeOwner}" label="Take Ownership" /> -->
    </lightning:card>
</aura:component>


caseTileController:
({
    doInit : function(component, event, helper){
        console.log('Do an action but nothing happens');
        alert('Loaded the set timer function');
       

    },
    
    navigateToDetailsView : function(component) {
        var c = component.get("v.case");
        console.log(c);
        var myEvent = $A.get("e.force:navigateToSObject");
        myEvent.setParams({
            "recordId": c.Id
        });
        myEvent.fire();
        console.log(myEvent);

	},

	caseSelected : function(component) {
        
		var c = component.get("v.case");
        console.log(c);
        var myEvent = $A.get("e.ltng:selectSObject");
        console.log(myEvent);
        myEvent.setParams({"recordId": c.Id, channel: "Cases"});
        myEvent.fire();
    }
   
})


caseTileHelper:
({
  handleSaveRecord: function(component, event, helper) {
      console.log('value of component: ' + component);
      alert(component.find("case.id"));
        component.find("case.id").saveRecord($A.getCallback(function(saveResult) {
            if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                console.log("Save completed successfully.");
            } else if (saveResult.state === "INCOMPLETE") {
                console.log("User is offline, device doesn't support drafts.");
            } else if (saveResult.state === "ERROR") {
                
                var errorParse = JSON.stringify(saveResult.error[0].message); 
                console.log('The value of errorParse is: ' +errorParse);
                alert('Problem saving record, error: ' + 
                           errorParse);
            } else {
                console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
            }
        }));
    }
})



caseList component:
<aura:component controller="CaseTileController" implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="cases" type="Case[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="c:QueueChange" action="{!c.onQueueChange}" />
    <aura:attribute name="selectedQueue" type="string" />
    <aura:attribute name="isDataReturned" type="boolean" default="false"/>
    <c:streaming channel="/event/CaseChange__e" onMessage="{!c.eventFired}" />
    <lightning:layout horizontalAlign="left" class="slds-theme_shade">
        <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<lightning:icon iconName="standard:case" size="large" alternativeText="Case Queue" class="slds-p_small" />
            <span class="slds-text-heading_medium"> &nbsp; Case Queue</span>
        </lightning:layoutItem>
   		<lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<c:QueueSelector /> 
        </lightning:layoutItem>
    </lightning:layout>
    <lightning:layout horizontalAlign="left" multipleRows="true" title="Case Queue" class="slds-theme_shade">        
        <aura:if isTrue="{!v.isDataReturned}">            
            <aura:iteration items="{!v.cases}" var="c" >
                <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
                    <c:caseTile case="{!c}" />
                </lightning:layoutItem>
            </aura:iteration>
            <aura:set attribute="else">
                <div class="slds-align_absolute-center" >
                    <div class="empty-state-container slds-text-align_center" >
                        <img src="/projRes/ui-home-private/emptyStates/noTasks.svg" />
                        <div class="empty-state-message slds-m-top_medium" >                            
                            Check back later, there are no current cases in the queue.
                            {!selectedQueue}
                        </div>
                    </div>
                </div>
            </aura:set>
        </aura:if>
    </lightning:layout>

</aura:component>


caseListController:
({
	doInit : function(component, event, helper) {        
       helper.getCases(component);


	},

    eventFired : function(component, event, helper){
		helper.getCases(component);
      
     },
    
    onQueueChange: function(component, event, helper){
        component.set("v.selectedQueue", event.getParam("selectedQueue"));
        helper.getCases(component);
    }
})


caseListHelper:
({
	checkForChanges : function(component, event, helper) {
		var action = component.get("c.getAvailableCases");
        action.setCallback(this,function(data){
           component.set("v.cases",data.getReturnValue()); 
        });
        $A.enqueueAction(action);
	},
    
    getCases : function(component, page){
        var action = component.get("c.getAvailableCases");
        action.setParams({
            "queueSelection" : component.get("v.selectedQueue")
        });
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var results = response.getReturnValue(); 
                component.set("v.cases",results); 
                component.set("v.isDataReturned", true);
                alert('Value of results: '+ JSON.stringify(results));
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
           
        });
        
        $A.enqueueAction(action);
    }
})

 
KdKomalKdKomal
Hi please try with the below code :-

caseTile
<aura:component >
	<aura:attribute name="case" type="case"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 
    <aura:registerEvent name="navigateToSObject" type="force:navigateToSObject"/>
    <aura:registerEvent name="selectSObject" type="ltng:selectSObject"/>
        <lightning:card >        
            <aura:set attribute="title" >
            	<a onclick="{!c.caseSelected}" style="color: black; ">
                    <div class="slds-align_absolute-center">
                    Name: <aura:if isTrue="{#v.case.Contact.Name!=undefined}">                        
                        {#v.case.Contact.Name}
                        <aura:set attribute="else">
                            {#v.case.SuppliedName}
                        </aura:set>
                    </aura:if>
                    </div>
                </a>
        	</aura:set>
           
            <a onclick="{!c.caseSelected}" style="color: black; ">
                
                <p class="slds-p-horizontal--small">
                	Requested Advisor: {#v.case.Requested_Advisor_Counselor__c}                
            	</p>
                <p class="slds-p-horizontal--small">
                	Type: {#v.case.Type}
                </p>
                <p class="slds-p-horizontal--small">
                    Time in queue: <ui:outputNumber value="{#v.case.Total_minutes_in_the_queue__c}" />
                </p>
                <label aura:id="minutes">00</label>:<label aura:id="seconds">00</label>
                
           </a> 
            <!--<lightning:button onclick="{!c.changeOwner}" label="Take Ownership" /> -->
    </lightning:card>
</aura:component>

CaseList
<aura:component controller="CaseTileController" implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="cases" type="Case[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
     <aura:handler event="c:QueueChange" action="{!c.onQueueChange}" />
  

    <aura:attribute name="selectedQueue" type="string" />
    <aura:attribute name="isDataReturned" type="boolean" default="false"/>
    <lightning:layout horizontalAlign="left" class="slds-theme_shade">
        <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<lightning:icon iconName="standard:case" size="large" alternativeText="Case Queue" class="slds-p_small" />
            <span class="slds-text-heading_medium"> &nbsp; Case Queue</span>
        </lightning:layoutItem>
   		<lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	
            <c:QueueSelector />

        </lightning:layoutItem>
    </lightning:layout>
    <lightning:layout horizontalAlign="left" multipleRows="true" title="Case Queue" class="slds-theme_shade">        
        <aura:if isTrue="{!v.isDataReturned}">            
            <aura:iteration items="{!v.cases}" var="c" >
                <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
                    <c:caseTile case="{!c}" />
                </lightning:layoutItem>
            </aura:iteration>
            <aura:set attribute="else">
                <div class="slds-align_absolute-center" >
                    <div class="empty-state-container slds-text-align_center" >
                        <img src="/projRes/ui-home-private/emptyStates/noTasks.svg" />
                        <div class="empty-state-message slds-m-top_medium" >                            
                            Check back later, there are no current cases in the queue.
                            {!selectedQueue}
                        </div>
                    </div>
                </div>
            </aura:set>
        </aura:if>
    </lightning:layout>
<c:streaming channel="/event/CaseChange__e" onMessage="{!c.eventFired}" />
</aura:component>

As you can see the alert showing the loading of timer is popped up.

Just for the Info :- I commented out the <c:streaming> and <c:QueueSelector> as i did not have the same in my org. This caused the init function to fire(Probably). Request you to try once commenting them in your code and check.
Richard Houston GMURichard Houston GMU
I got it firing the child method! With refernce to this post:

https://salesforce.stackexchange.com/questions/156214/call-function-in-child-component-from-the-parent-component/156243
  • Added an aura:method to the child component
  • Updated the parent markup to include an aura:id on the iterated component.
  • Added a for loop in the parent helper to fire the method for each item in the iteration. 
Here's the updated code:

caseTile:
 
<aura:component >
	<aura:attribute name="case" type="case"/>
    <aura:handler name="init" value="{!v.case}" action="{!c.doInit}" /> 
    <aura:registerEvent name="navigateToSObject" type="force:navigateToSObject"/>
    <aura:registerEvent name="selectSObject" type="ltng:selectSObject"/>

//Here is the additional aura:method I added   

 <aura:method name="setTimer" access="PUBLIC" action="{!c.doInit}" />

// This allows the parent component to call an action of the child component.

        <lightning:card >        
            <aura:set attribute="title" >
            	<a onclick="{!c.caseSelected}" style="color: black; ">
                    <div class="slds-align_absolute-center">
                    Name: <aura:if isTrue="{#v.case.Contact.Name!=undefined}">                        
                        {#v.case.Contact.Name}
                        <aura:set attribute="else">
                            {#v.case.SuppliedName}
                        </aura:set>
                    </aura:if>
                    </div>
                </a>
        	</aura:set>
           
            <a onclick="{!c.caseSelected}" style="color: black; ">
                
                <p class="slds-p-horizontal--small">
                	Requested Advisor: {#v.case.Requested_Advisor_Counselor__c}                
            	</p>
                <p class="slds-p-horizontal--small">
                	Type: {#v.case.Type}
                </p>
                <p class="slds-p-horizontal--small">
                    Time in queue: <ui:outputNumber value="{#v.case.Total_minutes_in_the_queue__c}" />
                </p>
                <label aura:id="minutes">00</label>:<label aura:id="seconds">00</label>
                
           </a> 
            <!--<lightning:button onclick="{!c.changeOwner}" label="Take Ownership" /> -->
    </lightning:card>
</aura:component>

caseList component:
 
<aura:component controller="CaseTileController" implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="cases" type="Case[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="c:QueueChange" action="{!c.onQueueChange}" />
    <aura:attribute name="selectedQueue" type="string" />
    <aura:attribute name="isDataReturned" type="boolean" default="false"/>
    <c:streaming channel="/event/CaseChange__e" onMessage="{!c.eventFired}" />
    <lightning:layout horizontalAlign="left" class="slds-theme_shade">
        <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<lightning:icon iconName="standard:case" size="large" alternativeText="Case Queue" class="slds-p_small" />
            <span class="slds-text-heading_medium"> &nbsp; Case Queue</span>
        </lightning:layoutItem>
   		<lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >
        	<c:QueueSelector /> 
        </lightning:layoutItem>
    </lightning:layout>
    <lightning:layout horizontalAlign="left" multipleRows="true" title="Case Queue" class="slds-theme_shade">        
        <aura:if isTrue="{!v.isDataReturned}">            
            <aura:iteration items="{!v.cases}" var="c" >
                <lightning:layoutItem padding="around-small" size="12" smallDeviceSize="6" mediumDeviceSize="4" largeDeviceSize="3" >

<!-- I added the "aura:id="caseInList"" to reference in the updated helper code -->
                    <c:caseTile case="{!c}" aura:id="caseInList"/>

                </lightning:layoutItem>
            </aura:iteration>
            <aura:set attribute="else">
                <div class="slds-align_absolute-center" >
                    <div class="empty-state-container slds-text-align_center" >
                        <img src="/projRes/ui-home-private/emptyStates/noTasks.svg" />
                        <div class="empty-state-message slds-m-top_medium" >                            
                            Check back later, there are no current cases in the queue.
                            {!selectedQueue}
                        </div>
                    </div>
                </div>
            </aura:set>
        </aura:if>
    </lightning:layout>

</aura:component>

caseListHelper:
 
({
	checkForChanges : function(component, event, helper) {
		var action = component.get("c.getAvailableCases");
        action.setCallback(this,function(data){
           component.set("v.cases",data.getReturnValue()); 
        });
        $A.enqueueAction(action);
	},
    
    getCases : function(component, page){
        var action = component.get("c.getAvailableCases");
        action.setParams({
            "queueSelection" : component.get("v.selectedQueue")
        });
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var results = response.getReturnValue(); 
                component.set("v.cases",results); 
                component.set("v.isDataReturned", true);

// start of new code
// Reference the aura:id in the caseList component to create a new set of objects.
// I then iterate over the objects in the variable to call the child method using the 
// setTimer aura:method.

                var childObject = component.find('caseInList');
                alert('Value of childOjbect: '+childObject);
                for (var i = 0; i < childObject.length; i++){
                    childObject[i].setTimer();
                }

// end the block of new code

            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
           
        });
        
        $A.enqueueAction(action);
    }
})

 
KdKomalKdKomal
Hi Richard,

That's great to hear. The only think i am concerned about is that whenever a new component is loaded doInit is fired automatically. Even though with this approch desired results are obtained but this was a very strange behaviour.

But glad it worked out for you.  Cheers !
just one thing change  <aura:handler name="init" value="{!v.case}" action="{!c.doInit}" /> to  <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> in caseTile component.
Richard Houston GMURichard Houston GMU
Thanks Komal. I will make the change to the handler, and will look for a way to keep this function from firing too often. I appreciate all the help!