2

I have a lightning component on the opportunity layout. I want it to refresh on stage change. Currently, it works when you change the stage using the edit button using the following code.

<aura:dependency resource="markup://force:recordSaveSuccess" type="EVENT" />
<aura:handler event="force:refreshView" action="{!c.doInit}" />

When changing stage using the Sales Path component (pic below for reference), this event does not seem to be fired. Has anyone been able to subscribe to this component's events? Am I missing something? Sales Path Component

1
  • Hey..How did you fix this..Please help ..I want to do the same thing.
    – miku
    Jan 30, 2017 at 3:44

2 Answers 2

3

You can't "subscribe" to another component's events since they're in the component's namespace, not your component's. That's part of what the locker service was all about - to maintain a separation between namespaces and the code that runs in each one.

You can only watch for Application level Events that are passed from within a component and shared with the application through a component's Notifier Component for Events 'Registered' with the Application. Once the a notifier component executes, the Event becomes available to the Application. I believe an issue will be that the component is typically also what's registered as the handler of that Event as well (again, more name spacing can be involved here).

For more on this, see Event Handling Lifecycle and the adjacent sections of the documentation.

1
  • Hi.Can you please help how did you fix this..I want to do exactly the same thing.
    – miku
    Jan 30, 2017 at 3:42
3

Ran through similar requirement and I did some hack to make it work. I added these 2 lines into code and it worked !!!!

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

This Line listens page refresh/Record detail page change event, so rfreshes my component on inline change of detail tab.

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

This one refreshes my component when stage or key fields on sales coach component is modified (Which i think your requirement is). I checked through JS from salesforce for sales path coach component, when they are done with update successfully they fire this application level event on screen. Which can be listened and further its parameters can be read to check purpose of it, then accordingly you can handle this in your component.

It worked for me!! hope it helps for you as well.

You must log in to answer this question.

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