0

I have created one component and added to lightning console app as utility bar component. And I have created an application event. I would like to navigate another component when event fired with parameters.

But I am getting error like 'Uncaught Action failed: [Cannot read property 'setParams' of undefined' Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <div class="slds-modal__container">
        <div class="logo">
            <img src="/resource/demoAdapterLogo" align="center"></img>
        </div>
        <div class="slds-form-element slds-p-bottom--medium">
            <label class="slds-form-element__label" for="text-input-01">Username</label>
            <div class="slds-form-element__control">
                <ui:inputText class="slds-input"/>
            </div>
        </div>
        <div class="slds-form-element slds-p-bottom--medium">
            <label class="slds-form-element__label" for="text-input-01">Password</label>
            <div class="slds-form-element__control">
                <ui:inputSecret class="slds-input"/>
            </div>
        </div>
        <button class="slds-button slds-button--brand" aura:id="submitButton" onclick="{!c.handleLogin}">Log In</button>
    </div>
</aura:component>

Controller:

({    
    handleLogin : function(component, event) {
        console.log('Controller handle click...');
          var appEvent = $A.get("e.c:phonePanelEvent");
        appEvent.setParams({ 'presence': 'Available'});
        appEvent.fire();  

    },

})

Event:

<aura:event type="APPLICATION" description="Event template">
    <aura:attribute name="presence" type="String"/>
</aura:event>

1 Answer 1

2

Hi if you have custom event then you have to register it before use. Please add the following line in your component to register event <aura:registerEvent name="appEvent" type="c:phonePanelEvent"/> For more reference please have a look on salesforce docs for Application Event Example

1
  • Thanks @Rishi for your response. But application event is not triggered. Handled Component: <aura:handler name="cmp" event="c:phonePanelEvent" action="{!c.renderPanelCmp}"/> HandledCmp Controller: renderPanelCmp: function (cmp, event, helper) { var typevar = event.getParam("presence") }
    – Ajay
    Commented Aug 22, 2017 at 7:26

You must log in to answer this question.

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