0

I am using one main lightning component and all other components are opening within the main components. I want to update the browser URL when the user navigates. I am trying to navigate to a component in the community to update the URL. But it's not working. I used below code:

 var pageReference = {   
        "type": "standard__component",
        "attributes": {
            "componentName": "c__Target"    
        },    

    };
    navService.generateUrl(pageReference)
    .then($A.getCallback(function(url) {
        cmp.set("v.url", url ? url : defaultUrl);
    }), $A.getCallback(function(error) {
        cmp.set("v.url", defaultUrl);
    }));

In the community it gives null value in url but in salesforce lightning its working fine.

I have also tried this but it didn't https://rajvakati.com/2018/11/13/navigate-to-component-using-lightningnavigation/

1 Answers1

0

Try to use comm__namedPage instead of standard__

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_navigation_page_definitions.htm

In Communities, the value for pageName is the URL value for a supported page. For instance, the default URL value for the Account Management page is /account-management, so the value for pageName would be account-management.

The value of home is reserved for the landing page of any community in your org.

However, because pages in communities are different than pages in Lightning Experience, we’ve moved them to their own namespace for better management and clarity. standard__namedPage is deprecated in communities. Use comm__namedPage instead.

{
type: "comm__namedPage",
attributes: {
    pageName: "home"
}
Pablo Gonzalez
  • 1,197
  • 10
  • 21