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
abu saleh khan 20abu saleh khan 20 

Problem calling component from another component using lightning:isUrlAddressable

Hi I am getting this error when i call one component from another component by clicking on the button.

Comp2CompNav:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:isUrlAddressable" description="c:Comp2CompNav component" access="global" >
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doinit}"/>
    Hello {!v.firstname}.
</aura:component>    

js: 
({
    doinit: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.c__firstname;
        console.log('Check value with new way of fetching: '+firstname);
        cmp.set("v.firstname", firstname);
    }
})


Comp2CompNav2:
From this component I am calling another Component.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" description="c:Comp2CompNav2 component" access="global" >
    
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doinit }"/>
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Navigate" onclick="{!c.handleClick}"/>
</aura:component>    


js:

({
    doinit : function(component, event, helper) {
        var pageReference = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__Comp2CompNav',
            },
            state: {
                "c__firstname": "John"
            }
        };
        component.set("v.pageReference", pageReference);
     },
     handleClick: function(component, event, helper) {
        var navService = component.find("navService");
        var pageReference = component.get("v.pageReference");
       // event.preventDefault();
        navService.navigate(pageReference);
    }
})

Error Message
Best Answer chosen by abu saleh khan 20
Khan AnasKhan Anas (Salesforce Developers) 
Hi Abu,

Greetings to you!

According to lightning:isUrlAddressable documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation):

This navigation feature is supported only in Lightning Experience and the Salesforce App.

This component is not supported in Lightning Application but only in Lightning Experience and Salesforce Mobile App.

Also, see below release notes (https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_lc_components_navigation.htm) for New Lightning Navigation APIs for Lightning Components:

Where: This change applies to orgs with Lightning components in Lightning Experience and all versions of the mobile app. These resources aren’t supported in other containers, such as Lightning Components for Visualforce, Lightning Out, or Communities. This is true even if you access these containers inside Lightning Experience or the Salesforce mobile app.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Abu,

Greetings to you!

According to lightning:isUrlAddressable documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation):

This navigation feature is supported only in Lightning Experience and the Salesforce App.

This component is not supported in Lightning Application but only in Lightning Experience and Salesforce Mobile App.

Also, see below release notes (https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_lc_components_navigation.htm) for New Lightning Navigation APIs for Lightning Components:

Where: This change applies to orgs with Lightning components in Lightning Experience and all versions of the mobile app. These resources aren’t supported in other containers, such as Lightning Components for Visualforce, Lightning Out, or Communities. This is true even if you access these containers inside Lightning Experience or the Salesforce mobile app.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
abu saleh khan 20abu saleh khan 20
Thankyou khan.
ChellappaChellappa
 Khan , is there any solution for this? I am using a Lightning App ( Not LE or SFDC app) accessible via a browser URL.
Any pointers much appreciated. 
Even navigateToComponent is deprecated for this situation. 

Thanks,
Chellappa