+ Start a Discussion
Vandana Rattan 4Vandana Rattan 4 

Uncaught expeption in action callback: Cannot read property 'set' of undefined

I created a Lightning app sometime back. It was working fine some days back but now I am getting the exception Uncaught expeption in action callback: Cannot read property 'set' of undefined when I try to access it using the URL. Can anyone please guide me on this?

App
<aura:application implements="force:appHostable">
    <link href='/resource/bootstrap/' rel="stylesheet"/>
   
    <aura:handler event="c:navigateToForm" action="{!c.navigateToForm}"/>
    <aura:attribute name="presName" default="None" type="String" />
     <aura:attribute name="presDate" type="Date" />
    <aura:attribute name="evtName" type="String" default="----None----"/>
    <aura:attribute name="loggedIn" type="Boolean"/>
    <!--<aura:attribute name="presType" type="String" /> -->
    
    <div class="container-fluid" aura:id="content">
     
            
       
    <c:loginForm presName="{!v.presName}" presDate="{!v.presDate}" evtName="{!v.evtName}"/>
    <!--<aura:if isTrue="{!v.loggedIn}"><c:registrationForm presName="{!v.presName}" presDate="{!v.presDate}" evtName="{!v.evtName}"/></aura:if>-->
        <aura:renderIf isTrue="{!v.loggedIn}">
            <c:registrationForm presName="{!v.presName}" presDate="{!v.presDate}" evtName="{!v.evtName}"/>
        </aura:renderIf>
        
        
    </div>
	
</aura:application>
AppController
 
({
	navigateToForm : function(component, event, helper) {
      );
		var dest = "markup://c:" + event.getParam("view") + "Form";
      
        $A.componentService.newComponentAsync(this, function(view) {
          
            var content = component.find("content");
              
            content.set("v.body", view);
            //component.set("v.body", "Hello World!");
        },  {
            componentDef: dest,
            attributes: {
                values: {
                    presName: "{!v.presName}",
                    presDate: "{!v.presDate}",
                    evtName: "{!v.evtName}"
                    //presType: "{!v.presType}",
                }
            }
        }, component);
	}
})

cmp1
 
<aura:component controller="loginFormController" access="global" implements="force:appHostable">
    <link href='/resource/bootstrap/' rel="stylesheet"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!--<aura:registerEvent name="navigateToForm" type="c:navigateToForm"/>-->
    <!--<aura:handler event="c:navigateToForm" action="{!c.handleNavigation}"/>-->
    <aura:attribute name="loggedIn" type="Boolean" default="false"/>
	<aura:attribute name="registrations" type="Registrations__c[]"/>
    <aura:attribute name="login" type="Registrations__c"
        default="{ 'sobjectType': 'Registrations__c',
        'Event_Presenter__c': '',
        'Event_Date__c': '',
        'Event_Name__c': ''
        
    }"/>
   
   <aura:attribute name="presName" type="String" />
    <aura:attribute name="presDate" type="Date" />
    <aura:attribute name="evtName" type="String" />
    <!--<aura:attribute name="presType" type="String" />-->
    <aura:attribute name="isInHouse" type="Boolean" default="true" />
    
    
    <div class="container main-container">
        <!--<p><img src="/resource/EAHeader/"/></p>-->
         <table width="100%">
            <tr>
            <td style="text-align:left;">
            <img src="/resource/login/"/>
                </td>
            <td style="text-align:right;">
        <img src="/resource/EALogo/" />
                </td>
            
            </tr>
        </table>
        
       
    <form>
        <fieldset>
        <br></br>
        <br></br>
        <br></br>           
       
        <ui:inputText aura:id="presenterName" label="Presenter Name"
        class="form-control input-lg"
        value="{!v.presName}" required="false"/>
        
        <br></br>
        <br></br>
          
        <ui:inputDate aura:id="presentationDate" label="Presentation Date"
        class="form-control input-lg"
        value="{!v.presDate}" displayDatePicker="true"/>
        
         <br></br>
         <br></br>
            
        <ui:inputSelect aura:id="evName" label="Event Name"
        class="form-control input-lg" value="{!v.evtName}" change="{!c.onEvtNameChange}">
        	 <ui:inputSelectOption text="In-house Presentation"/>
        	 <ui:inputSelectOption text="Engineers Australia Event"/>
             <ui:inputSelectOption text="External Industry Event"/>
             <ui:inputSelectOption text="Other"/>
        </ui:inputSelect>
         
         <br></br>
         <br></br>
            <!--<div id="over" class="overlay" >
        
            <ui:inputText aura:id="presentationType" label="Presentation Type"
            class="form-control input-lg"
            value="{!v.presType}" required="false"/>
        	<br></br>
            <br></br>
            <br></br>
            </div>-->
            
         
            
        <ui:button class="btn-xlarge" label="Login" press="{!c.gotoForm}"/>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
             <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
             <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
        </fieldset>
    </form>
    
</div>  
</aura:component>
cmp1 Controller
({
	doInit : function(component, event, helper) {
      
		helper.getUserDetails(component);
        helper.getCurrentDate(component);
        
	},
    
    gotoForm : function(component, event, helper) {
        console.log("Navigating to Regitration Form >>>>>>>>>>>>>>>>>");
        //helper.getUserDetails(component);
        var evt = $A.get("e.force:navigateToComponent");
   
        if(evt == null){
        	
            evt = $A.get("e.c:navigateToForm");
            evt.setParams({view: "registration"}).fire();
        }
        else{
            evt.setParams({
                componentDef: "c:registrationForm",
                componentAttributes: {
                	presName: component.get("v.presName"),
                    presDate: component.get("v.presDate"),
                    evtName: component.get("v.evtName"),
                    //presType: component.get("v.presType")
            	}
                
        	});
    		evt.fire();  
        }
      
       
       component.set("v.showLogin",false);
        component.set("v.loggedIn",true);
    },
    
    onEvtNameChange: function(cmp, evt) {
         var selectCmp = cmp.find("evName");
         //resultCmp = cmp.find("singleResult");
         console.log("Inside onEvtNameChange >>" + selectCmp );
         console.log("selectCmp.get(\"v.value\") >>>" + selectCmp.get("v.value") );
        var evt = selectCmp.get("e.toggle");
        console.log("evt>>>>" + evt);
        var el = document.getElementById("over");
        if(selectCmp.get("v.value") == "In-house Presentation"){
            //cmp.set("v.isInHouse","false");
            el.style.visibility = "visible";
            //cmp.
        }
        else{
            el.style.visibility = "hidden";
        }
        
        
       
   },

    
  
})



 
Vandana Rattan 4Vandana Rattan 4
An edit: The app seems to be laoding fine in IPAD simulator. But e.forceNavigateToCompnent event does not seem to work now (as per other blog posts). This has put me in a fix!! I need to fix this ASAP. Also, why the app is not loading fine when accessed from URL?
Abhilash MAbhilash M
Yes I faced the same error today in my App.

Did you fix it, pls let me know
THE ImmuTHE Immu
Use $A.createComponent() instead of the deprecated $A.newCmp() and $A.newCmpAsync() methods.
link:https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_dynamic_cmp_async.htm