1

In my test project I'm trying to subscribe on Save Event using. Currently I'm using force:refreshView event to dispatch changes to my custom lightning component. I use this line and all works perfectly.

<aura:handler event="force:refreshView" action="{!c.doInit}" />

But after that I tried to subscribe on force:recordSaveSuccess using similar syntax

<aura:handler event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/>

But Developer Console doesn't allow to save and execute this script and Display an error

Failed to save undefined: A aura:handler that specifies an event="" attribute must handle an application event. Either change the aura:event to have type="APPLICATION" or alternately change the aura:handler to specify a name="" attribute.: Source

That literally mean that I need to add name attribute to this handler.

Could anyone explain why I can use force:refreshView without name attribute, but I have to add this attribute for force:recordSaveSuccess? I didn't find anything valuable in SF Lightning doc.

1 Answer 1

3

In general component event requires name attribute to be defined in the aura:handler. See the handling of component event for more info.

Look at the doc on force:recordSaveSuccess it pretty much clear that it is an component event, which is why it's handler without name defined threw an error.

2
  • why it's not required for force:refreshView? Jan 31, 2017 at 6:54
  • @AdelNazirov It's because force:refreshView is an application event and it's Salesforce decision to keep it this way.
    – Praveen
    Jan 31, 2017 at 9:19

You must log in to answer this question.

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