I have to open a lightning component from a button on related list. Hence I created a list button in child object and added it on the page layout of parent object.
I created a list button with URL as below
/lightning/cmp/c__Commercial_Opportunity_Product?c__firstName="Nilang"
Commercial_Opportunity_Product is the name of my lightning component. I have passed firstName as parameter. Below is the code of Commercial_Opportunity_Product component.
<aura:component implements="lightning:actionOverride,lightning:isUrlAddressable,force:lightningQuickActionWithoutHeader,force:hasRecordId,flexipage:availableForAllPageTypes">
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="parentId" type="String"/>
<aura:attribute name="firstName" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.onPageReferenceChange}"/>
<div class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<div class="slds-modal__content slds-p-around--medium">
<div>
<header class="slds-modal__header">
<h2 class="slds-modal__title">New Commercial Opportunity Product</h2>
<p> Hello {!v.firstName}</p>
</header>
<div class="slds-p-vertical_small slds-text-body_medium">
<lightning:recordEditForm aura:id="form"
recordId="{!v.recordId}"
objectApiName="GEFUE_Commercial_Opportunity_Product__c"
class="slds-card__body_inner">
<h2 class="slds-section-title--divider">Information</h2>
<div class="slds-grid slds-gutters">
<lightning:messages/>
<div class="slds-col ">
<lightning:inputField fieldName="GEFUE_Terminal__c" aura:id="terminalLookupId"/>
<lightning:inputField fieldName="GEFUE_Product__c" aura:id="productLookupId"/>
</div>
<div class="slds-col">
<lightning:inputField fieldName="GEFUE_Opportunity__c" aura:id="oppLookupId"/>
</div>
</div>
</lightning:recordEditForm>
</div>
</div>
</div>
</div>
</div>
Below is code of its controller
({
onPageReferenceChange : function(component, event, helper) {
var myPageRef = component.get("v.pageReference");
var firstname = myPageRef.state.c__firstName;
component.set("v.firstName", firstname);
}
})
But when opening this component via the URL button in related list, it is taking me to another page and giving below error.
This page isn't available in Salesforce Lightning Experience or mobile app.
Below is the screenshot
Am I missing something here? I have also implemented lightining:isUrlAddressable for launching lightning component via a URL.