I'm trying initialize an array of custom object and I get the following error:

Error during init [TypeError: Cannot read property 'apply' of undefined]

Object Name: Expense__c

Namespace: imaginicom

I have declared the attribute like this in Form Component.

<aura:attribute name="expenses" type="imaginicom.Expense__c[]"/>  

<!-- Display expense records -->
      <div class="container slds-p-top--medium">
          <div id="list" class="row">
             <aura:iteration items="{!v.expenses}" var="expense">



Form Controller

    doInit : function(component, event, helper) {


Form Helper

    getExpenses : function(component) {

       var action = component.get("c.getExpense");

       action.setCallback(this, function(response) {

           if (component.isValid()) {

               //This is where I get error
               component.set("v.expenses", response.getReturnValue() ); 




Apex Class

public with sharing class ExpenseController {

    public static List<Expense__c> getExpense(){

        // Perform isAccessible() check here
        return [SELECT Id, Name, Amount__c, Client__c, Date__c,
        Reimbursed__c, CreatedDate FROM Expense__c];



Kindly help me out.

1 Answer 1


You need to tweak your attribute definition.

Change it to:

<aura:attribute name="expenses" type="imaginicom__Expense__c[]"/>

You had defined it as namespace.ObjectName when it should be namespace__ObjectName

For more examples, usages, go here

  • I tried it like imaginicom__Expense__c[] , but that too didn't work. Sep 23, 2016 at 8:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .