1

I think I have a grasp on the difference of COMPONENT and APPLICATION level events, and how to use them - however, I am running into a situation I cant get around.

  1. Lightning App configured
  2. Lightning Record Page defined for ObjectA contains instance of custom component "Notifications"
  3. Lightning Record Page defined for ObjectB contains instance custom component "Notifications"
  4. ObjectB record page contains another custom component for handling the modification of records in ObjectB. When you take specific actions in this custom component it generates a notification to appear in the "Notifications" component using an Application event. This is working as intended.
  5. In Lightning Console Application, I open ObjectA record, and then open related ObjectB record. The ObjectB loads, and generates its notification list. I click on the ObjectA subtab that is also already open, and unfortunately it is now also showing the same notifications.

I am already filtering the event firing by recordId - the instance of "Notifications" has the recordId available to it. Somehow the event is firing in ObjectB component, generating in the Notifications component as expected, but replicating across all instances of the component with no apparent way to stop it from happening.

event.stopPropagation(); does not appear to stop the event from replicating - just propagation. I am not having a problem with it going up the hierarchy.

I have tried to look into using GlobalID tags, COMPONENT level events instead, etc.

It looks like if you have a standard lightning record page with a component in a lightning console app you dont have access to control the container and its event handling to the level necessary.

Can anyone confirm or suggest another solution?

I need component to component communication when those two components are in a lightning record page in a lightning console application.

  • 1
    Please edit your question to include additional updates, instead of using comments, unless you're replying to a comment. Comments are ephemeral and may be deleted at any time. – sfdcfox Aug 7 '18 at 1:51
1

Thanks to re-re-re reading this thread I was able to find a solution that works.

  • I was already implementing force:hasRecordId
  • I was already sending the active recordId in the event payload
  • I was already checking to make sure the recordId wasnt blank in the payload
  • I was unfortunately not making sure the active component recordId was identical to the inbound event payload recordId.

As soon as I made that change it works as expected.

Reference: How to link Lightning Components using events inside a Lightning App Builder page?

  • Create an application type event
  • Add recordId as an event attribute
  • Set up your originating component to fire the event, with the active record recordId as a parameter
  • Set up your receiving component to receive the event, checking that the active record recordId of the receiving component matches the inbound event payloads recordId

This is now working in lightning console app, with multiple instances of the same component across multiple lightning record pages without causing the same event to update each instance.

If you wanted to put multiple instances of the same component on the same record page you would have to add some way to target the specific component, but it could potentially be done with additional attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.