1

Hi I am trying to replace the standard new button in one of the related list of the Quote object. I am succesfully doing it except that when the custom button is clicked, the modal is displayed on a separate page instead on the Quote record detail page as a pop-up. I'm quite stucked on this one, can someone help me with this?

Visualforce:

<apex:page standardController="Quote" recordSetVar="quotes" tabStyle="quote" lightningStylesheets="true">
    <apex:includeScript value="/lightning/lightning.out.js" />
    <div id="lightning" />
            <script>
            $Lightning.use("c:myCustomApp", function() {
                $Lightning.createComponent("c:myCustomComp",
                                           { label : "object Creation" },
                                           "lightning",
                                           function(cmp) {
                                               //

                                           });
            });
            </script>
    </apex:outputPanel>
</apex:page>

myCustomApp:

<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:myCustomComp"/> 
    <aura:dependency resource="markup://force:*" type="EVENT"/>
</aura:application>

myCustomComp

<aura:component controller="MYController" access="global" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable,force:lightningQuickAction">
    <aura:attribute name="recordId" type="Id"/>
    <lightning:notificationsLibrary aura:id="notifLib"/>
  
    <div aura:id="exampleModal" class="slds-modal slds-fade-in-open hideDiv" aria-hidden="false" role="dialog">
        <section role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open slds-modal_small" aria-labelledby="modal-heading-01" aria-modal="true">
            <div class="slds-modal__container">
                //my FORM       
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open" role="dialog"></div> 
    </div>
    
</aura:component>
2
  • 3
    You're not stuck--it's literally impossible to do what you ask using Lightning Out.
    – sfdcfox
    Commented Mar 22, 2022 at 11:00
  • Thank you so much @sfdcfox for replying! Do you have an idea/suggestion to achieve this? I'm trying to mimic the standard New button on the related list so it has to be a visualforce but the look and feel should be lightning
    – Charlie
    Commented Mar 22, 2022 at 12:48

1 Answer 1

0

You should be able to link to your component directly from the button. Just make it URL addressable, and then use the URL list button type, such as:

/lightning/cmp/c__myCustomComp?c__id={!Account.Id}

You can still have it look like a modal, but the page behind will be navigated to a new temporary tab. This is, I believe, the only way to stay in the same window and use your component.

You must log in to answer this question.

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