I am getting this error on Step 3 (Developer Guide - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/qs_aotp_app_step3_model.htm)

This page has an error. You might just need to refresh it. Error during init [Assertion Failed!: Unknown controller action 'getExpenses' : undefined]

Any help would be appreciated.

2 Answers 2


Apparently the JS and Apex controllers are called expensescontroller and Expensescontroller respectively, it affects Trailhead looking for getExpenses () in JS, even though the APEX controller is created. The solution implemented to approve the challenge was to rename the APEX controller to "ExpenseController" without the "s" after Expense, so the app already correctly displays the list of expenses.

In expenses.cmp the ExpenseController is called

<aura:component controller="ExpenseController">
<aura:attribute name="newExpense" type="Expense__c"
default="{ 'sobjectType': 'Expense__c',
                'Name': '',
                'Amount__c': 0,
                'Client__c': '',
                'Date__c': '',
                'Reimbursed__c': false }"/>
<aura:attribute name="expenses" type="Expense__c[]"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>

And the APEX ExpenseController:

public with sharing class ExpenseController {

public static List<Expense__c> getExpenses() {

    // Check to make sure all fields are accessible to this user
    String[] fieldsToCheck = new String[] {
        'Id', 'Name', 'Amount__c', 'Client__c', 'Date__c', 
        'Reimbursed__c', 'CreatedDate'

    Map<String,Schema.SObjectField> fieldDescribeTokens = 

    for(String field : fieldsToCheck) {
        if( ! fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
            throw new System.NoAccessException();
            return null;

    // OK, they're cool, let 'em through
    return [SELECT Id, Name, Amount__c, Client__c, Date__c, 
                   Reimbursed__c, CreatedDate 
            FROM Expense__c];
public static Expense__c saveExpense(Expense__c expense) {
    // Perform isUpdatable() checking first, then
    upsert expense;
    return expense;

That was the solution. And this is the execution of expenses.app enter image description here


Hard to tell for sure without code for context, but either your JS Lightning controller doesn't have a method called getExpenses or your Apex controller doesn't.

I suspect it's the Apex class at fault. Check that your method (assuming your have written it) is defined as public static.

You must log in to answer this question.

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