0

I have overriden Opportunity new button with Aura component below. Then I am trying to navigate from aura to LWC with a backgroundContext which means i want to open the lwc just in front of list view . But currently the page is opening with a blank background,

enter image description here

I am trying to open it on top of list view

 <aura:component implements="lightning:actionOverride,lightning:isUrlAddressable" access="global" >
    
    
         <aura:handler name="init" value="{! this }" action="{! c.myAction }"/>
          <lightning:navigation aura:id="navService"/>
    </aura:component>

JS

({
    myAction : function(component, event, helper) {
        var navService = component.find("navService");
        var compDefinition = {
            type: 'standard__component',
            componentDef: "c:newoppwizard",
            attributes: {
            },
            state: {
                nooverride: 1,
                navigationLocation: 'LIST_VIEW',
                backgroundContext: '/lightning/o/Opportunity/list?filterName=Recent'
                //backgroundContext: back_url
            }
        };
        let encodedCompDef = btoa(JSON.stringify(compDefinition));
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url": "/one/one.app#" + encodedCompDef
        });
        urlEvent.fire();
    }
})
2
  • Hi.. community.. any idea how to fix this Commented Jul 4, 2022 at 18:00
  • Remove the New Button from Object Manager > Opportunity > List View Button Layout Create a new Action on Opportunity Object, let's say 'New'. Choose Lightning Web Component and select your Component from the dropdown. Commented Nov 20 at 11:39

1 Answer 1

-1

Consider if you want LWC on Account ListView.

  • Make sure you've added 'lightning__RecordAction as target and its target configs as well. meta-file

  • Create a quick action on the Account object, select Action Type as Lightning Web Component, and select your LWC component.

For the List View Button

  • Create a Dummy Account and restrict its deletion.
  • Create a New Button or Link on the Account object, select Display Type as 'List Button' and Content source as 'URL'
  • In the formula box, paste '{!$Site.CurrentSiteUrl}/lightning/action/quick/Account.Upload_Excel_File?objectApiName&context=RECORD_DETAIL&recordId=<18-Digit-Dummy-AcccountId>&backgroundContext=%2Flightning%2Fo%2FContact%2Flist%3FfilterName%3D__Recent '.

Now go to Object Manager and add the Button to the Account List View Layout. This will render lwc on list view page without the need of Aura Component, and will also retain the background.

New contributor
Prashant Srivastava is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • 4
    You should reproduce the important parts here. Salesforce has a pretty bad reputation when it comes to link longevity.
    – Derek F
    Commented Dec 10 at 16:03
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Dec 11 at 4:34

You must log in to answer this question.

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