[SalesForce] Opening a Visual Force page which embeds a lightning component from Related List button

Problem: I have a requirement which says, need to open a modal window which opens on click of related list button and this modal needs to be a lightning component,As we cant open a lightning component from related list button I achieved this by embedding this lightning component in a Visualforce page and then including this page in the related list button and then selected the option to open in existing window, so right now what i am facing is that the modal component isn't opening as a popup rather than its opening in a separate tab within the service console.

Possible solution: I skipped the popup part and added it as a lightning quick action and it works fine.

What suggestion i am looking for:
Is there a way to open a lightning component from related list button?
If i am opening a visualforce page which has the modal component, is there a way to restrict it from opening it in a new tab instead open as a popup on existing record page layout?

Best Answer

My initial thought was to use a javascript button to inject a modal but that wont work with a lightning component.

A tiny bit of research pulled up this:

Lightning Alternatives to JavaScript buttons

Which goes into detail on how to avoid using JavaScript buttons - which ironically includes custom related list buttons - but it doesn't seem to cover your specific use case. It actually advises not using javascript buttons and using lightning component quick actions instead which you have said you tried and that it works but it doesn't provide the exact experience you're looking for.

The last thing I can think of is that you can hide the related list from your page and build a lightning component that looks and acts like the same related list. This will allow you to add a button that could then pull in your other component.

Related Topic