getParam Not Working on Simple Application Event

Salesforce Asked on December 21, 2020

I have a button which when pressed causes an application event to fire. Before it does this it sets a string value using setParam. The event is fired and handled successfully. However, when I try to console.log the string value from the event it just says undefined. Can anyone help?


<aura:event type="APPLICATION" description="MovieGenreEvent">
<aura:attribute name="movieYear" type="String"/>

Component firing the event:

<aura:component description="MovieSearchSlider" implements="flexipage:availableForAllPageTypes" access="global">

<aura:attribute name="SliderValue" type="String" default="2003" />
<aura:registerEvent name="MovieGenreEvent" type="c:MovieGenreEvent" />
<lightning:button variant="brand" label="Fire!" iconName="utility:check" iconPosition="left" onclick="{!c.handleClick}" />



    handleClick : function(component, event) {

        let sliderValue = component.get("v.SliderValue");
        var applicationEvent = $A.get("e.c:MovieGenreEvent");
        applicationEvent.setParams({"movieYear" : sliderValue});;

Component Receiving the event:

<aura:component description="movieSearchList" controller="movieSearchController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
<aura:attribute name="movieYearFilter" type="String"/>
<aura:handler event="c:MovieGenreEvent" action="{!c.handleEvent}" />


    handleEvent : function(component, event, helper) {

    console.log('event = ' + event.getParam("movieYear"));


event = undefined
{setParams: ƒ, setParam: ƒ, fire: ƒ, getName: ƒ, getParam: ƒ, …}

One Answer

This is very strange but I just added a boolean attribute to the event, components and controllers. Not only did this arrive in the handler but it also seems to have caused the string to come through too. I have since removed the boolean, and the string is still there. It's possible that I did not save one of the aura definitions however this really doesn't seem likely given the logging I added. Otherwise maybe it's a bug on my instance.. Either way thanks to @Kal and @Jayant for your assistance, much appreciated.

Answered by Jay on December 21, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP