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
Kumar GKumar G 

Error during init [Action failed: c:Tasklist$controller$gettask [helper.gettask is not a function]]

Hi Everyone,
I have created a Lightning component to retrieve list of tasks , while running the code i am getting this error : Action failed: c:Tasklist$controller$gettask [helper.gettask is not a function.

Please find my code and help me out to resolve this issue.
<aura:component controller="LightTaskListController" implements="force:appHostable">

     <aura:attribute name="Tasks" type="Task[]"/>
	 
    <aura:handler name="init" value="{!this}" action="{!c.gettask}" />
	
    <table class="slds-table slds-table--bordered slds-max-medium-table--stacked-horizontal">
	
        <thead>
            <tr class="slds-text-heading--label ">
                <th class="" scope="col">Task Name</th>
                <th class="slds-is-sortable" scope="col">Number Of Seats</th>
                <th class="slds-is-sortable" scope="col">License Plate</th>
                <th class="slds-is-sortable" scope="col">License Expiration Date</th>
                <th class="slds-is-sortable" scope="col">Fuel</th>                
            </tr>  
        </thead>
		
        <tbody>
		
            <aura:iteration items="{!v.Tasks}" var="tsk">
			
                <tr class="slds-hint-parent">
                    <td class="" data-label="Status" >
                        <a href="{! '#/sObject/' + tsk.Id + '/view'}">{!tsk.Status}</a>
                    </td>
					
                    <td data-label="Subject" style="padding-left:0;">
					        <ui:outputtext value="{!tsk.Subject}" />
					</td>
					
                    <td data-label="Priority" style="padding-left:0;">
                        <a href="{! '#/sObject/' + tsk.Id + '/view'}">{!tsk.Priority}</a>
				    </td>
						
                    <td data-label="Activity Date" style="padding-left:0;">{!tsk.ActivityDate}</td>
					
                    <td data-label="Description " style="padding-left:0;">{!tsk.Description }</td>                
                </tr>
				
            </aura:iteration>
			
        </tbody>
		
    </table>  
</aura:component>
 
Controller : 

({
gettask : function(component, event, helper) {
        helper.gettask(component);
    	}
})
 
Helper class : ({
  getVehicle : function(component) {
        var action = component.get("c.gettaskList");
        action.setCallback(this, function(a) {
            component.set("v.Tasks", a.getReturnValue());
        });
        $A.enqueueAction(action);
    
	}
})
 
Apex class : public with sharing class LightTaskListController{
    @AuraEnabled
    public static List<Task> gettaskList() {
        return [select Id,Priority,ActivityDate,Subject,Status,Description from Task];
    }    
}
Thanks in advance..
 
SonamSonam (Salesforce Developers) 
Hi Kumar,

You seem to be getting th.t error as the name of the function in helper in GetVehicle and not gettask:
Please update the code as shown below - I've highlighted the changes I've made:

Component:

<aura:component controller="LightTaskListController" implements="force:appHostable"> <aura:attribute name="Tasks" type="Task[]"/> <aura:handler name="init" value="{!this}" action="{!c.gettask}" /> <table class="slds-table slds-table--bordered slds-max-medium-table--stacked-horizontal"> <thead> <tr class="slds-text-heading--label "> <th class="" scope="col">Task Name</th> <th class="slds-is-sortable" scope="col">Number Of Seats</th> <th class="slds-is-sortable" scope="col">License Plate</th> <th class="slds-is-sortable" scope="col">License Expiration Date</th> <th class="slds-is-sortable" scope="col">Fuel</th> </tr> </thead> <tbody> <aura:iteration items="{!v.Tasks}" var="tsk"> <tr class="slds-hint-parent"> <td class="" data-label="Status" > <a href="{! '#/sObject/' + tsk.Id + '/view'}">{!tsk.Status}</a> </td> <td data-label="Subject" style="padding-left:0;"> <ui:outputtext value="{!tsk.Subject}" /> </td> <td data-label="Priority" style="padding-left:0;"> <a href="{! '#/sObject/' + tsk.Id + '/view'}">{!tsk.Priority}</a> </td> <td data-label="Activity Date" style="padding-left:0;">{!tsk.ActivityDate}</td> <td data-label="Description " style="padding-left:0;">{!tsk.Description }</td> </tr> </aura:iteration> </tbody> </table> </aura:component>
 

Controller : ({ gettask : function(component, event, helper) { helper.getVehicle(component); } })
 
Helper class : ({ getVehicle : function(component) { var action = component.get("c.gettaskList"); action.setCallback(this, function(a) { component.set("v.Tasks", a.getReturnValue()); }); $A.enqueueAction(action); } })