+ Start a Discussion
Vigneshwaran LoganathanVigneshwaran Loganathan 

Pass Parameter Using Lightning Navigation

Hi All, The link https://rajvakati.com/2018/11/13/navigate-to-component-using-lightningnavigation/ where Source Component passes parameters to Target and the parameters are visible in URL.. 

I am following the exact steps but its not passing parameters to mt Target Component, neither can I see any Parameters in URL.. Is there anything I am doing wrong? 

I have added the component in Account Details Page.. 

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <lightning:navigation aura:id="navService"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:attribute name="url" type="String"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <lightning:button label="Open Lightning Component" onclick="{!c.handleClick}"/>
    init : function(cmp, event, helper) {
        var navService = cmp.find("navService");
        var pageReference = {
            "type": "standard__component",
            "attributes": {
                "componentName": "c__Target"    
            "state": {
                "firstName": "Test"  ,
                "lastName": "user"    
        cmp.set("v.pageReference", pageReference);
        var defaultUrl = "#";
        .then($A.getCallback(function(url) {
            cmp.set("v.url", url ? url : defaultUrl);
        }), $A.getCallback(function(error) {
            cmp.set("v.url", defaultUrl);
    handleClick: function(cmp, event, helper) {
        var navService = cmp.find("navService");
        // Uses the pageReference definition in the init handler
        var pageReference = cmp.get("v.pageReference");

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:isUrlAddressable" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.init}" />

    <aura:attribute name="firstName" type="String" />
    <aura:attribute name="lastName" type="String" />
        Full Name : {!v.firstName} + {!v.lastName}
    init: function(cmp, event, helper) {
        var pageReference = cmp.get("v.pageReference");
        cmp.set("v.firstName", pageReference.state.firstName);
        cmp.set("v.lastName", pageReference.state.lastName);

Below is the URL which when I clicked from Account Page - without Parameters

User-added image



Best Answer chosen by Vigneshwaran Loganathan
Vigneshwaran LoganathanVigneshwaran Loganathan
I have posted the same and got answer here -- https://salesforce.stackexchange.com/questions/274242/pass-parameter-using-lightning-navigation#274244