+ Start a Discussion

page redirection not woking in lightning


I am using page redirection to populate values.
the page redirection works well in Classic but not in lightning

        returnURL.getParameters().put('oppid', '006b000000RFaG9AAL');
        returnURL.getParameters().put('accid', '001b000000nMoZ1AAK');
What is trick in lightning to do so

thank you for suggestion
Best Answer chosen by Sandrine
Danish HodaDanish Hoda
Hi Sandrine,
You would need to use Navigation system In Lightning.
You can refer to : https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation

All Answers

Danish HodaDanish Hoda
Hi Sandrine,
You would need to use Navigation system In Lightning.
You can refer to : https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation
This was selected as the best answer
Deepali KulshresthaDeepali Kulshrestha
Hi Sandrine,

I've gone through your requirement ,see below to know about how to use page reference in lightning:

Use lightning:navigation component to navigate to a given pageReference or to generate a URL from a pageReference.

The following example generates a URL to an Account Object home based on its pageReference and sets the URL on an <a> element. The example
assumes that you're creating the component for a custom Lightning Component tab or a Lightning page by implementing force:appHostable and

Lightning component-->

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <aura:attribute name="url" type="String"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <lightning:navigation aura:id="navService"/>
    <a href="{!v.url}">Link</a>

In your client-side controller, set the pageReference attribute for the Account home page. Set the URL on your link using the generateUrl()
method, which is useful for opening links in a new tab. Depending on whether you’re using the new URL format available as part of the Summer ’18 
critical update, you might see a URL that begins with the new format /lightning/cmp/ or the old format one/one.app#/cmp/.

    init : function(cmp, event, helper) {
        var navService = cmp.find("navService");
        // Sets the route to /lightning/o/Account/home
        var pageReference = {
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'home'
        cmp.set("v.pageReference", pageReference);
        // Set the URL on the link or use the default if there's an error
        var defaultUrl = "#";
            .then($A.getCallback(function(url) {
                cmp.set("v.url", url ? url : defaultUrl);
            }), $A.getCallback(function(error) {
                cmp.set("v.url", defaultUrl);

You can also navigate directly to a page using a onclick handler.

<lightning:navigation aura:id="navService"/>
<a href="{!v.url}" onclick="{!c.handleClick}">Link</a>
<lightning:button label="Navigate" onclick="{!c.handleClick}"/>
In your client-side controller, use the navigate() method to navigate to the page.

    handleClick: function(cmp, event, helper) {
        var navService = cmp.find("navService");
        // Uses the pageReference definition in the init handler
        var pageReference = cmp.get("v.pageReference");

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha