+ Start a Discussion
Semira@gmail.comSemira@gmail.com 

How to pass ParentID in a URL from Lightning Component

Hi, 

This might be one of the recurrance questions but I cannot seem to find the answer. I have been trying to resolve this for quiet a few months now. So here is my scenario. 

I have overwritten the New button with a visualforce page of a related list object(invoice__c) from Opportunity. However, this does not work with Console so I tried to write a simple Component re-directing user to the Visualforce page to create a new invoice. When using the lightning component, the ParentID (opportunity ID) is not passed to the new Invoice page. Opportunity has a lookup relationship to invoice. 

How do I pass the opportunity Id through lightning component? 
<aura:component implements="force:appHostable,lightning:actionOverride,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
  
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
</aura:component>
Note below: I tried to apply the same method as URL hacking. Obviously it's a fail. I'm not too familiar with URL parameter setting. So, I tried this method to see if it would work. 
({
	doInit : function(component, event, helper) {
		var ID = $A.get("v.recordId");
        var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url":"/apex/ATIInvoicePage?Opportunity__c="+ID
        
    });
    urlEvent.fire();
	}
})