Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Hi, 

I have a custom button in a login flow that needs to navigate to an external website. Below is the code I have for the component and controller, but I think the button needs to redirect to a new tab and open the URL there (the button doesn't navigate the user anywhere). 

Component

<aura:component implements="lightning:availableForFlowScreens" access="global">

<lightning:button variant="brand" label="Find My Closer" title="Find My Closer" onclick="{! c.navigate }" />

</aura:component>

Controller:

({

navigate : function(component, event, helper) {

var urlEvent = $A.get("e.force:navigateToURL");

urlEvent.setParams({

"url": 'https://www.google.com'

});

urlEvent.fire();

}

})

Any help is appreciated.

Thanks in advance!​
3 answers
  1. Jul 14, 2018, 6:51 AM
    Hi Matt Hitt

     

    // Component//

    <aura:component implements="force:appHostable">

        <div id="aura-page">

            <div class="container">

                <ui:button label="gotoURL" press="{!c.gotoURL}" />

            </div>

            <div class="container">

                

                <lightning:button variant="brand" label="Find My Closer" title="Find My Closer" onclick="{! c.navigate }" />

            </div>

        </div>

    </aura:component>

    //Controller//

    ({

        gotoURL : function(component, event, helper) {

            helper.gotoURL(component);

        },

        navigate : function(component, event, helper) {

            helper.navigate(component);

        }

    })

    // Helper Controller//

    ({

        gotoURL : function (component) {

            var urlEvent = $A.get("e.force:navigateToURL");

            urlEvent.setParams({

              "url": "/006/o"

            });

            urlEvent.fire();

        },

        navigate : function(component) {

            var address = '/Salesforce.com+Inc/@37.793779,-122.39448,17z/';

            var urlEvent = $A.get("e.force:navigateToURL");

            urlEvent.setParams({

              "url": 'https://www.google.com/maps/place/' + address

            });

            urlEvent.fire();

        }

    })

    if you found this answer helpful then please mark it as best answer so it can help others.   

      

      Thanks 

      Akshay
Loading
0/9000