+ Start a Discussion
Stefan van der KnaapStefan van der Knaap 

lightning error during init

Hi,

I'm stuck with a Lightning component that doesn't render. I get a strange error immediately: This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined].

I'm stuck now for a long time and can't figure out what is wrong with the code. Here you can see my code:

Component:
<aura:component controller="CaseActivityTrackerCtrl" implements="flexipage:availableForAllPageTypes">

	<aura:attribute name="recordId" type="String" default='500b000000cOxah' />
	<aura:attribute name="case" type="Case" />
	<aura:attribute name="tasks" type="Task[]"/>

	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

	<c:CaseActivityTrackerHeader />

	<aura:iteration items="{!v.tasks}" var="task">
		<c:CaseActivityTrackerTimeline task="{!task}"/>
	</aura:iteration>

	<aura:iteration items="{!v.tasks}" var="task">
		<h3>{!v.task.Subject}</h3>
	</aura:iteration>

	<h3>{!v.case.Subject}</h3>
	<h3>{!v.recordId}</h3>

</aura:component>
({
    doInit: function(component, event, helper) {
    	//helper.getCase(component, event);
		//helper.getTasks(component, event);
        // Set the attribute value. 
        // You could also fire an event here instead.
        component.set("v.recordId", "controller init magic!");
    }
})
App
 
<aura:application extends="force:slds">
    
    <c:CaseActivityTracker />
    
    <!-- 
    <c:camping />
	-->
    
</aura:application>

I really somebody can help me!
Thanks in advance, Stefan
 
Best Answer chosen by Stefan van der Knaap
Stefan van der KnaapStefan van der Knaap
Found it! It was in the helperclass (which I no realise I didn't post here) and it was a variable 'case' that SFDC interpreted as a sobject case instead of var case. By changing the var name to 'Case' the issue was fixed

All Answers

Stefan van der KnaapStefan van der Knaap
Found it! It was in the helperclass (which I no realise I didn't post here) and it was a variable 'case' that SFDC interpreted as a sobject case instead of var case. By changing the var name to 'Case' the issue was fixed
This was selected as the best answer
merul shahmerul shah

Hey,

This is very general error salesforce throw. I got the same error for different reason. Best way to debug is pressing F12 and do console debuging and you will find thee actual  error.

hope this additional information helps you @stefan  

SaraHasNoLimitsSaraHasNoLimits
I think the suggestion by merul shah is actually the best answer. I had the same issue and once I went to the console log, I saw exactly what was causing the problem, which in my case was a missing ).
ghurooghuroo
It may be caused by a Chrome Extension.
Try disabling each one at a time and refresh the Salesforce page.

In my case, the Chrome Extension causing troubles was "React-Sight".
ramanareddy maddirala 5ramanareddy maddirala 5
To load records but iam not gerrting records from appex class please help me where i done the mistake.
<aura:component controller="OpportunityController">
    <aura:attribute name="opportunities" type="Opportunity[]"/>
    <ui:button label="Get Opportunities" press="{!c.getOpportunities}"/>
    <aura:iteration var="opportunity" items="{!v.opportunities}">
        <p>{!v.opportunity.Name}:{!v.opportunity.CloseDate}</p>
    </aura:iteration>
</aura:component>

Controller:

({
    getOpps: function(cmp){
        var action = cmp.get("c.getOpportunities");
        /*action.setParams({ opportunities : cmp.get("v.opportunities") });*/

        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set("v.opportunities", response.getReturnValue());
            }
           /* 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);
    }
})

Appex class:

public class OpportunityController {
@auraenabled
    public static list<opportunity> getopper(){
        list<opportunity> op=[select id,name,CloseDate from opportunity ];
        system.debug(op);
        return op;
    }
    @AuraEnabled
    public static Opportunity getOpportunity(Id id) {
        Opportunity opportunity = [
                SELECT Id, Account.Name, Name, CloseDate, 
                       Owner.Name, Amount, Description, StageName
            FROM Opportunity
            WHERE Id = :id
         ];

        // Perform isAccessible() check here 
        return opportunity;
    }
}