I have created a Lightning Component Tab and i have to pass parameter in its url (Specifically Opportunity Id). Email with link will be sent to the user and when user clicks on that link that component will open after user login into the salesforce. Any suggestion to pass and fetch the Opportunity Id from url?


1 Answer 1


Welcome to StackExchange, Gaurav!

As of the Summer '18 release, you can use the lightning:isUrlAddressable interface to expose the page URL via the pageReference attribute, like this:

Include the interface name in the "implements" parameter of your component tag:

<aura:component implements="lightning:isUrlAddressable">

Then, in your javascript controller, you can get the value for any property in the URL querystring by reference to the page state:

If your URL has OpportunityId=12345 in the querystring, this will set the oppId attribute equal to 12345:

init: function(cmp, evt, helper) {
    var myPageRef = cmp.get("v.pageReference");
    var opportunityId = myPageRef.state.OpportunityId;
    cmp.set("v.oppId", opportunityId);

You must log in to answer this question.

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