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

$A.get(applicationEvent) returning undefined and Uncaught TypeError: Cannot read property 'setParams' of undefined

Hi All,

when I'm trying to call application event then I'm getting below error and $A.get(event) is returning undefined which is marked bold in the below code.
Error : Uncaught TypeError: Cannot read property 'setParams' of undefined
CalendarView.cmp  :

<aura:component controller="CalendarController" implements="force:hasRecordId,force:hasSObjectName,force:appHostable" access="global">
<aura:registerEvent name="loadMyEvent" type="harshabr:ResultEvent"/>
    <ltng:require styles="/resource/gpcal_lex_yo_SLDS0121/assets/styles/salesforce-lightning-design-system-ltng.css,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.css" 
	<aura:attribute name="recordId" type="String" access="global"/>
	<aura:attribute name="sObjectName" type="String" access="global"/>	
	<aura:attribute name="user_id" type="String" />
    <aura:attribute name="cal" type="Boolean" default="true" />
	<aura:attribute name="evtRec" type="List" />
    <aura:attribute name="eventId" type="String" />
     <aura:renderIf isTrue="{!}">
        <div id='calendar'>
        <!-- <c:EventsList evtId="{!v.eventId}" /> -->

CalendarViewController :

	doInit: function(component, event, helper){
	    	defaultView: 'month',
	    	allDaySlot: false,
	    	selectable: true,
			selectHelper: true,
			select: function(start, end) {
				var title = prompt("Please enter subject of event:");
				var eventData;
				if (title) {

					var action = component.get("c.createNewEvent");
					var params = { 
						start_time : start.format("YYYY-MM-DD HH:mm:ss"),
						end_time   : end.format("YYYY-MM-DD HH:mm:ss"),
						user_id    : component.get("v.user_id"),
						what_id    : component.get("v.recordId"),
						sobjectName    : component.get("v.sObjectName"),
						title      : title		

					action.setCallback(this, function(actionResult) {				        				        
				        if( actionResult.getReturnValue() ){
				        	$('#calendar').fullCalendar( 'refetchEvents' );
				        	console.log("save successful");

				        	alert( "Save failed for some reason." );


	    	events: function(start, end, timezone, callback) {
	    		var user_id = component.get("v.user_id");	    		
				var action = component.get("c.getEvents");
						start_time : start,
						end_time   : end,
						user_id    : user_id		

				action.setCallback(this, function(actionResult) {
            eventClick: function(calEvent, jsEvent, view) {
    	        console.log('gm calEvent '+calEvent);
                console.log('gm1 ';
                var evtId =;
                var evt = $A.get("e.c:ResultEvent");
				evt.setParams({ "pass_result": evtId });;

ResultEvent.evt :
<aura:event type="APPLICATION">
    <aura:attribute name="pass_result" type="String"/>


<aura:application extends="force:slds">
    <c:CalendarView />
    <c:EventsList />

EventsList.cmp :
<aura:component controller="CalendarController" access="global">
  <aura:attribute name="eventData" type="List" access="global" />
    <aura:handler event="harshabr:ResultEvent" action="{!c.getMyEvents}" />
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
      <tr class="slds-text-heading--label">
        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Subject">Subject</div></th>
        <th scope="col"><div class="slds-truncate" title="StartDateTime">StartDateTime</div></th>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.eventData}" var="e">
          <th scope="row"><div class="slds-truncate" title="{!e.Id}">{!e.Id}</div></th>
          <td><div class="slds-truncate" title="{!e.Subject}">{!e.Subject}</div></td>
          <td><div class="slds-truncate" title="{!e.StartDateTime}">{!e.StartDateTime}</div></td>
            <form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!e.Name}" class="account-name" />
               <!--  Use a Lightning Base Component
                To display an icon next to the label-->
              <lightning:button label="Delete"

 EventsListController :
getMyEvents: function(component, event, helper){
        var action = component.get('c.getEventss');
    	var evtIds = event.getParam("pass_result");
      	console.log('GM evtId '+evtIds);
        	  "eventId": evtIds
    	// Set up the callback
    	var self = this;
    	action.setCallback(this, function(actionResult) {
     		component.set('v.eventData', actionResult.getReturnValue());
      	console.log("GM res "+component.get('v.eventData'));
  deleteAccount: function(component, event, helper) {
    // Prevent the form from getting submitted

    // Get the value from the field that's in the form
    var accountName ='account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
Hi GM,

I think when you are calling ResultEvent event, you are not specifying the namespace.
It should be var evt = $A.get("e.harshabr:ResultEvent");

Hope this helps.
Hi Gauravendra,

Thanks for the reply but when I specify the namespace then I get same error since console.log(evt); is showing as undefined.

TypeError: evt is undefined throws at ....../auraFW/javascript/5HxA6PNAIzmJB2pSyRCygA/aura_proddebug.js line 5360 > eval:77:5

Pankaj GurbaniPankaj Gurbani
Enclosing your eventClick function in $A.getCallback() will fix it.
Like this: (Line 89)
eventClick: $A.getCallback(function(calEvent, jsEvent, view){ 
//your code

You're Welcome