function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AichaSFAichaSF 

lightning Component - URL - passing parameter

Hello, 

I have a lightning component that retrieves a phone parameter from the URL:
https:/XXXXX/lightning/cmp/c__LC01_ContactFoundCTI?telephone=+3312345

My Cmp code:
 
<aura:component controller="LCN01_ContactFoundCTI" implements="lightning:isUrlAddressable" access="global">

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="telephone" type="String" />

    <aura:attribute name="ContactNum" type="Decimal" /> 
    <aura:attribute name="erreur" type="String" />
    <aura:attribute name="show" type="boolean" default="true" />
	
    <div class="slds-modal__header">
     <aura:if isTrue="{!v.show}">
	<h2 class="slds-text-heading--medium" >Recherche de Contact en cours</h2>
     </aura:if> 
	<h2 class="slds-text-heading--medium" >phone = {!v.pageReference.state.telephone}</h2>     

    <h2 class="slds-text-heading--medium " > {!v.erreur}</h2>
</div>  
</aura:component>
The test does not recover the phone.

Can someone help me.
Ramesh DRamesh D
@AichaSF,
As per the documentation you need to use C__ to retrive the parameters if i'm not worng
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation

Try using 
{!v.pageReference.state.C__telephone}

I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D

 
Raj VakatiRaj Vakati
Use lightning:navigation component 
 
<aura:component implements="flexipage:availableForAllPageTypes">
     <aura:attribute name="url" type="String"/>

     <aura:handler name="init" value="{! this }" action="{! c.setPagref }"/>
     <lightning:navigation aura:id="navLink"/>
     <div>
        <a href="{!v.url}" target="_blank"> Go to Account </a> <br/>
        <lightning:button label="Andy Young" title="Andy Young" onclick="{!c.goToRec}" variant="success"/>
     </div>
</aura:component>
 
({
    setPagref : function(component, event, helper) {
        var navLink = component.find("navLink");

        var pageRef = {
            type: 'standard__objectPage',
            attributes: {
                actionName: 'list',
                objectApiName: 'Account',

            },
            state: {
                filterName: "MyAccounts"
            }
        };

        // Set the URL on the link or use the default if there's an error

        navLink.generateUrl(pageRef).then($A.getCallback(function(a) {
                component.set("v.url", a ? a : "#");
            }), $A.getCallback(function(error) {
                component.set("v.url", "#");
            }));
    },
    ge : function(component, event, helper) {
        var navLink = component.find("navLink");
        var pageRef = {
            type: 'standard__recordPage',
            attributes: {
                actionName: 'view',
                objectApiName: 'Contact',
                recordId : '0037FXXX51uq5QAA' // change record id. 
            },
        };
        navLink.navigate(pageRef, true);
    }
})

https://wedgecommerce.com/lightningnavigation-lightning-component/
https://thewizardnews.com/2018/08/02/url-hack-functionality-lightning/
https://rajvakati.com/2018/11/13/navigate-to-component-using-lightningnavigation/

https://rajvakati.com/2018/05/29/navigation-in-lightning-experience-using-pagereference/
http://simpluslabs.com/how-to-use-lightningnavigation-to-navigate-another-component/